Set money at first spawn -
Fiore - 03.12.2012
Hello, i'm trying to set money at first spawn with something like this:
pawn Код:
public OnPlayerConnect(playerid)
{
SetPVarInt(playerid, "FirstSpawn", 1); //The player is going to spawn for the first time
return 1;
}
public OnPlayerSpawn(playerid)
{
if(GetPVarInt(playerid, "FirstSpawn")) //If its the first time the player has spawned
{
GivePlayerMoney(playerid, 400);
SetPVarInt(playerid, "FirstSpawn", 0);
}
return 1;
}
But when i log in the money loads to 400 and when i try to buy smting it says that i do not have money (if i check /stats it says i do not have any money, with if i look at money Textdraw it says i've 400$), any suggestions?
Re: Set money at first spawn -
WoodPecker - 03.12.2012
Solved.
Re: Set money at first spawn -
zSuYaNw - 03.12.2012
Logic!
pawn Код:
public OnPlayerSpawn(playerid)
{
// Check if's "FirstSpawn" Variable is 0
if(!GetPVarInt(playerid, "FirstSpawn"))
{
// Send Money.
GivePlayerMoney(playerid, 400);
// Set variable "FirstSpawn" to 1.
SetPVarInt(playerid, "FirstSpawn", 1);
}
return 1;
}
#PS: Tested.
Re: Set money at first spawn -
Fiore - 03.12.2012
Money are still 0$, look at this:
pawn Код:
if (PlayerInfo[playerid][pFac] == 0)//Civ Spawn
{
if(GetPVarInt(playerid, "FirstSpawn")) //If its the first time the player has spawned
{
GivePlayerMoney(playerid, 3000);
SetPVarInt(playerid, "FirstSpawn", 1);
}
if(PlayerInfo[playerid][pHospital])
{
Hospital[playerid] = random(2);
if(Hospital[playerid] == 0)
{
SetPlayerPos(playerid, 2253.0479,360.5177,11.5480);
SetPlayerCameraPos(playerid,2249.8252,101.2665,41.2377);
SetPlayerCameraLookAt(playerid,2270.3330,82.0429,30.0284);
}
else if(Hospital[playerid] == 1)
{
SetPlayerPos(playerid, 2253.0479,360.5177,11.5480);
SetPlayerCameraPos(playerid,2249.8252,101.2665,41.2377);
SetPlayerCameraLookAt(playerid,2270.3330,82.0429,30.0284);
}
ResetZaiatWeapons(playerid);
PlayerInfo[playerid][pFacDuty] = 0;
SetPlayerVirtualWorld(playerid, 0);
TogglePlayerControllable(playerid, 0);
HospitalTime[playerid] = 30;
if(PlayerInfo[playerid][pVIP] >= 2) HospitalTime[playerid] = 1;
HospitalCountDown[playerid] = SetTimerEx("HospitalTimer", 1000, false, "d", playerid);
}
for(new i = 0; i < 13; i++)
if(PlayerInfo[playerid][pWeapon][i]) GiveZaiatWeapon(playerid, PlayerInfo[playerid][pWeapon][i], PlayerInfo[playerid][pWeaponAmmo][i]);
SetPlayerInterior(playerid,0);
SetPlayerVirtualWorld(playerid,0);
SetPlayerPos(playerid,2103.3633,-103.6316,2.2756);
SetPlayerFacingAngle(playerid, 301.8174);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 0);
SetPlayerSkin(playerid,PlayerInfo[playerid][pModel]);
return 1;
}
Re: Set money at first spawn -
zSuYaNw - 03.12.2012
Remove this from OnPlayerConnect
pawn Код:
SetPVarInt(playerid, "FirstSpawn", 1);
And, replace on OnPlayerSpawn:
pawn Код:
public OnPlayerSpawn(playerid)
{
// Check if's "FirstSpawn" Variable is 0
if(!GetPVarInt(playerid, "FirstSpawn"))
{
// Send Money.
GivePlayerMoney(playerid, 400);
// Set variable "FirstSpawn" to 1.
SetPVarInt(playerid, "FirstSpawn", 1);
}
return 1;
}
Re: Set money at first spawn -
Fiore - 03.12.2012
Do not work doing how you say, check this:
pawn Код:
if (PlayerInfo[playerid][pFac] == 0)//Civ Spawn
{
if(GetPVarInt(playerid, "FirstSpawn")) //If its the first time the player has spawned
{
GivePlayerMoney(playerid, 3000);
SetPVarInt(playerid, "FirstSpawn", 1);
}
if(PlayerInfo[playerid][pHospital])
{
Hospital[playerid] = random(2);
if(Hospital[playerid] == 0)
{
SetPlayerPos(playerid, 2253.0479,360.5177,11.5480);
SetPlayerCameraPos(playerid,2249.8252,101.2665,41.2377);
SetPlayerCameraLookAt(playerid,2270.3330,82.0429,30.0284);
}
else if(Hospital[playerid] == 1)
{
SetPlayerPos(playerid, 2253.0479,360.5177,11.5480);
SetPlayerCameraPos(playerid,2249.8252,101.2665,41.2377);
SetPlayerCameraLookAt(playerid,2270.3330,82.0429,30.0284);
}
ResetZaiatWeapons(playerid);
PlayerInfo[playerid][pFacDuty] = 0;
SetPlayerVirtualWorld(playerid, 0);
TogglePlayerControllable(playerid, 0);
HospitalTime[playerid] = 30;
if(PlayerInfo[playerid][pVIP] >= 2) HospitalTime[playerid] = 1;
HospitalCountDown[playerid] = SetTimerEx("HospitalTimer", 1000, false, "d", playerid);
}
for(new i = 0; i < 13; i++)
if(PlayerInfo[playerid][pWeapon][i]) GiveZaiatWeapon(playerid, PlayerInfo[playerid][pWeapon][i], PlayerInfo[playerid][pWeaponAmmo][i]);
SetPlayerInterior(playerid,0);
SetPlayerVirtualWorld(playerid,0);
SetPlayerPos(playerid,2103.3633,-103.6316,2.2756);
SetPlayerFacingAngle(playerid, 301.8174);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 0);
SetPlayerSkin(playerid,PlayerInfo[playerid][pModel]);
return 1;
}
I've this at moneycheat:
pawn Код:
// Money Anticheat
if(GetPlayerMoney(playerid) != PlayerInfo[playerid][pMoney])
{
//ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
}
Re: Set money at first spawn -
zSuYaNw - 03.12.2012
Replace:
pawn Код:
if(!GetPVarInt(playerid, "FirstSpawn")) //If its the first time the player has spawned
{
GivePlayerMoney(playerid, 3000);
SetPVarInt(playerid, "FirstSpawn", 1);
}
Re: Set money at first spawn -
Fiore - 03.12.2012
Money on stats are still 0, but on TD are 3000.
Re: Set money at first spawn -
zSuYaNw - 03.12.2012
pawn Код:
if(!GetPVarInt(playerid, "FirstSpawn")) //If its the first time the player has spawned
{
GivePlayerMoney(playerid, 3000);
PlayerInfo[playerid][pMoney] = 3000;
SetPVarInt(playerid, "FirstSpawn", 1);
}
send name of textdraw.
Re: Set money at first spawn -
Fiore - 03.12.2012
It's the default money's TD, under weapons.