I'm having a problem with my stock givecash. -
When I a new player connects, the script is told to givecash(playerid, 14500);
Okay, then they choose their starting car.
It takes 5000 from them, but before it takes 5000 from them it gives them another 14500.
I reversed this just to see what would happen. When they player spawned they had -5000. Then they bought the car, it took away another 5000 then gave them the 14500 giving the player 4500 cash left.
pawn Код:
stock GiveCash(playerid, amount)
{
new string[128];
if(amount < 0) format(string, sizeof(string), "~r~-$%d", amount*-1);
else if(amount > 0) format(string, sizeof(string), "~g~+$%d", amount);
GameTextForPlayer(playerid, string, 3000, 1);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
PlayerInfo[playerid][pCash] += amount;
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
return 1;
}
public OnPlayerSpawn(playerid)
{
if(playernew[playerid] == 1)
{
SetPlayerSkin(playerid, 294);
SetPlayerVirtualWorld(playerid, playerid);
SetPlayerPos(playerid, -1654.7256,1210.4141,7.2500);
SetPlayerFacingAngle(playerid, 72.4549);
SetCameraBehindPlayer(playerid);
TogglePlayerControllable(playerid, 0);
GiveCash(playerid, 14500);
SendClientMessage(playerid, -1, "Welcome to the server. Please choose a vehicle so we can get started with the tutorial.");
car1[playerid] = CreateVehicle(436,-1661.4111,1213.3392,7.0127,277.1554,random(255),random(255),1);
SetVehicleVirtualWorld(car1[playerid], playerid);
ShowPlayerDialog(playerid, 5, DIALOG_STYLE_MSGBOX,""COL_WHITE"Tier 1 - Manana",""COL_WHITE"Cost: $5000\nTop Speed: 5/10\n Acceleration: 3/10\n Handling: 5/10","Buy","Next");
playernew[playerid] = 0;
}
else
{
SendClientMessage(playerid, -1, "Welcome back.");
SetPlayerPos(playerid, -1654.7256,1210.4141,7.2500);
SetPlayerFacingAngle(playerid, 72.4549);
SetCameraBehindPlayer(playerid);
SetPlayerVirtualWorld(playerid, 0);
}
return 1;
}
if(dialogid == 5)
{
if(response)
{
SendClientMessage(playerid,-1, "Congratulations on your first purchase!");
SendClientMessage(playerid,-1, "Get in your Manana to start the tutorial.");
TogglePlayerControllable(playerid, 1);
GiveCash(playerid, -5000);
}
else
{
SendClientMessage(playerid, -1, "404!");
Kick(playerid);
}
return 1;
}
return 1;
}