All pastes #576987 Raw Edit

GambleV

public text v1 · immutable
#576987 ·published 2007-06-19 18:44 UTC
rendered paste body
#include <a_samp>
#include <core>
#include <float>
#include <file>
#include <dudb>
#include <dini>
//#include <dutils>

#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_SYSTEM_PW 0xFFFF33AA	// YELLOW (FFFF33) system personal warning ("you must be in a bank")
#define COLOR_MENU 0xFFFFFFAA		// WHITE (FFFFFF) menu's (/help)
#define COLOR_SYSTEM_GM 0xFF9966AA	// LIGHT ORANGE-RED (FF9966) system generated general message ("x just bought the four dragons!")
//#define FILE_SETTINGS "settings.ini"

#define MAX_3DLOCS 3

new Float:casCoords[MAX_3DLOCS][6] = { // {Xmin, Ymin, Zmin, Xmax, Ymax, Zmax}
	{1925.1511,968.2360,992.4687,1982.3024,1067.4122,995.5211}, // four dragons
	{2179.5100,1559.0856,1000.0,2281.1492,1622.9048,1010.0}, //caligula
	{1113.6541,-13.2672,1000.6718,1143.2858,12.4690,1003.0662} 	// redsands casino
};
new Float:casSpawn[MAX_3DLOCS][3] = {
	{2030.2551,1007.9247,10.8203}, // four dragons
	{2186.8896,1680.6750,11.1027}, //caligula
	{1658.9501,2255.8767,10.8203} // redsands casino
};


//new gamblelicence[MAX_PLAYERS];
//new spawned[MAX_PLAYERS];
new logged[MAX_PLAYERS];
new playername[MAX_PLAYER_NAME];
new strings[256];
new Float:X250[MAX_PLAYERS];
new Float:Y250[MAX_PLAYERS];
new Float:Z250[MAX_PLAYERS];
new isincasino[MAX_PLAYERS];
new currentmoney[MAX_PLAYERS];
//new tmps1[256];
new GameTextForPlayers1[MAX_PLAYERS][36];
new GameTextForPlayers2[MAX_PLAYERS][36];
new GameTextForPlayersCounter[MAX_PLAYERS];


new File:Casino;




public OnFilterScriptInit()
{
        //print("--CASINO GAMBLE--");
        SetTimer("CasinoUpdate", 1100, 1);

        
        if(!fopen("Casino",io_read))
        {
                print("\r\n\r\nError: Keine Casino Daten gefunden. Neue Daten Datei wird erstellt. (Server.exe schließen und neu starten!)");
                Casino=fopen("Casino",io_readwrite);
        }
        else
        {
                print("\r\n\r\nCasino Daten gefunden. Daten werden geladen...");
                Casino=fopen("Casino",io_readwrite);
        }
        fclose(Casino);
        return 1;
}


public Casino_No(playerid)
{
    new PName[MAX_PLAYER_NAME];

    GetPlayerName(playerid,PName,sizeof(PName));
    Casino=fopen("Casino",io_readwrite);
        dini_Set("Casino",PName,"N");
        fclose(Casino);
        return 1;
}

public Casino_Dis(playerid)
{
    new PName[MAX_PLAYER_NAME];

    GetPlayerName(playerid,PName,sizeof(PName));
    Casino=fopen("Casino",io_readwrite);
    dini_Set("Casino",PName,"D");
    fclose(Casino);
        return 1;
}

public Casino_Yes(playerid)
{
    new PName[MAX_PLAYER_NAME];

    GetPlayerName(playerid,PName,sizeof(PName));
    Casino=fopen("Casino",io_readwrite);
        dini_Set("Casino",PName,"Y");
        fclose(Casino);
        return 1;
}



public OnPlayerConnect(playerid)
{


        new PName[MAX_PLAYER_NAME];
        GetPlayerName(playerid,PName,sizeof(PName));
        Casino=fopen("Casino",io_readwrite);
        if(strcmp(dini_Get("Casino",PName),"Y",false)==0)
        {
            if(strlen(dini_Get("Casino",PName))==1) // seems streams with no data also run through this part.
            {
                fclose(Casino);
                }
                else // If there is no data present,
                {
                    Casino_No(playerid); // Make some!
                }
        }
        else if(strcmp(dini_Get("Casino",PName),"N",false)==0)
        {
            fclose(Casino);
        }
        else if(strcmp(dini_Get("Casino",PName),"D",false)==0)
        {
            fclose(Casino);
        }
        else
        {
                Casino_No(playerid);
        }
        return 1;
}









public OnPlayerCommandText(playerid, cmdtext[]){
new cmd[256];


if(strcmp(cmd, "/gamble", true) == 0) {
				new tracedIDName[MAX_PLAYER_NAME];
                //new strn[255];
	//#pragma unused params
	if (logged[playerid] == 1){

        GetPlayerName(playerid, playername, sizeof(playername));
        if(strcmp(dini_Get("Casino",tracedIDName),"Yes",true)==0)
               {
        SendClientMessage(playerid, COLOR_SYSTEM_PW, "* Du hast bereits eine GambleLizens");
        return 1;
                }
		if (logged[playerid] == 0) {
		    SendClientMessage(playerid, COLOR_SYSTEM_PW, "* Bitte logge dich ein, um zu spielen.");
		    return 1;
		}
		if (GetPlayerMoney(playerid) >= 7500){
			// TO-DO money scanner update
			//format(moneyreason, sizeof(moneyreason), "* Money decreased by $%d (old: $%d), because player-id %d bought a gamble licence",GAMBLE_LICENCE, GetPlayerMoney(playerid), playerid);
			GivePlayerMoney(playerid, -7500);
			//dini_IntSet(udb_encode(playername), "gamblelicence", 1);
			//gamblelicence[playerid] = 1;
			format(strings, sizeof(strings), "--- %s (id: %d) bought a gamble licence for $7500.", playername,playerid);
			printf(strings);
			format(strings, sizeof(strings), "* %s (id: %d) bought a gamble licence for $7500.", playername,playerid);
			SendClientMessageToAll(COLOR_SYSTEM_GM, strings);
			Casino_Yes(playerid);
		} else {
		    format(strings, sizeof(strings), "* Du hast nicht genug Geld fuer eine Spiellizens. Sie kostet $7500.");
			SendClientMessage(playerid, COLOR_SYSTEM_PW, strings);
			return 1;
		}
	}
	return 1;
}

return 0;
}




//



public CasinoUpdate()
{
new PName[MAX_PLAYER_NAME];

	if((strcmp(dini_Get("Casino",PName),"Y",false)==0))

	for(new i=0; i<MAX_PLAYERS; i++) {
		if(IsPlayerConnected(i)) {
          for(new j=0; j < MAX_3DLOCS; j++) {
				if(X250[i] >= casCoords[j][0] && X250[i] <= casCoords[j][3] && Y250[i] >= casCoords[j][1] && Y250[i] <= casCoords[j][4] && Z250[i] >= casCoords[j][2] && Z250[i] <= casCoords[j][5]) {
     				//if (strval(tmps1) == 1) {
					    //if(gamblelicence[i] == 1) {
					        isincasino[i] = 1;
					        currentmoney[i] = GetPlayerMoney(i);
							return 1;
					    } else {
					    	
					        format(GameTextForPlayers1[i], 36, "~w~DU HAST KEINE GAMBLE LICENCE");
					        format(GameTextForPlayers2[i], 36, "KAUFE EINE MIT /GAMBLE!");
							GameTextForPlayersCounter[i]=5;
				   			SetPlayerInterior(i, 0);
							SetPlayerPos(i, casSpawn[j][0], casSpawn[j][1], casSpawn[j][2]);
							
						//} else {
					if(isincasino[i] == 1){
					    isincasino[i] = 0;
					    return 1;
					}
				//}
            }
		}
	}
 	//return 1;
//}

}
return true;
}