help with money - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: help with money (
/showthread.php?tid=362830)
help with money -
Scorpion Yemen - 25.07.2012
i need cmd that have /cash [id] to give player money,
plz help guys
Re: help with money -
Vince - 25.07.2012
Re: help with money -
Scorpion Yemen - 25.07.2012
i search and find with zcmd i want with the normal one plz guys
Re: help with money -
Rudy_ - 25.07.2012
pawn Код:
if(strcmp(cmd, "/givecash", true) == 0)
{
new tmp[256];
new string[128];
new playermoney;
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new giveplayerid, moneys;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_5, "USAGE: /givecash [playerid] [amount]");
return 1;
}
giveplayerid = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_5, "USAGE: /givecash [playerid] [amount]");
return 1;
}
moneys = strval(tmp);
//printf("givecash_command: %d %d",giveplayerid,moneys);
if (IsPlayerConnected(giveplayerid))
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
playermoney = GetPlayerMoney(playerid);
if (moneys > 0 && playermoney >= moneys)
{
GivePlayerMoney(playerid, (0 - moneys));
GivePlayerMoney(giveplayerid, moneys);
format(string, sizeof(string), "You gave %s(player: %d), $%d.", giveplayer,giveplayerid, moneys);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string, sizeof(string), "You got $%d from %s(player: %d).", moneys, sendername, playerid);
SendClientMessage(giveplayerid, COLOR_GREEN, string);
PlayerPlaySound(playerid,1084,0.0,0.0,0.0);
printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
}
else
{
SendClientMessage(playerid, COLOR_RED, "Jou dont have so much ;)");
}
}
else
{
format(string, sizeof(string), "%d not found.", giveplayerid);
SendClientMessage(playerid, COLOR_RED, string);
}
return 1;
}
Re: help with money -
Scorpion Yemen - 25.07.2012
i got many errors
PHP код:
C:\Users\MOHAMMED\Desktop\xxxxxxxxxxxxxx\gamemodes\derby.pwn(870) : error 017: undefined symbol "cmd"
C:\Users\MOHAMMED\Desktop\xxxxxxxxxxxxxx\gamemodes\derby.pwn(878) : error 017: undefined symbol "strtok"
C:\Users\MOHAMMED\Desktop\xxxxxxxxxxxxxx\gamemodes\derby.pwn(878) : error 033: array must be indexed (variable "tmp")
C:\Users\MOHAMMED\Desktop\xxxxxxxxxxxxxx\gamemodes\derby.pwn(882) : error 017: undefined symbol "COLOR_5"
C:\Users\MOHAMMED\Desktop\xxxxxxxxxxxxxx\gamemodes\derby.pwn(887) : error 017: undefined symbol "strtok"
C:\Users\MOHAMMED\Desktop\xxxxxxxxxxxxxx\gamemodes\derby.pwn(887) : error 033: array must be indexed (variable "tmp")
C:\Users\MOHAMMED\Desktop\xxxxxxxxxxxxxx\gamemodes\derby.pwn(890) : error 017: undefined symbol "COLOR_5"
C:\Users\MOHAMMED\Desktop\xxxxxxxxxxxxxx\gamemodes\derby.pwn(930) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
7 Errors.
and this FS :
PHP код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmd, "/givecash", true) == 0)
{
new tmp[256];
new string[128];
new playermoney;
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new giveplayerid, moneys;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_5, "USAGE: /givecash [playerid] [amount]");
return 1;
}
giveplayerid = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_5, "USAGE: /givecash [playerid] [amount]");
return 1;
}
moneys = strval(tmp);
//printf("givecash_command: %d %d",giveplayerid,moneys);
if (IsPlayerConnected(giveplayerid))
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
playermoney = GetPlayerMoney(playerid);
if (moneys > 0 && playermoney >= moneys)
{
GivePlayerMoney(playerid, (0 - moneys));
GivePlayerMoney(giveplayerid, moneys);
format(string, sizeof(string), "You gave %s(player: %d), $%d.", giveplayer,giveplayerid, moneys);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string, sizeof(string), "You got $%d from %s(player: %d).", moneys, sendername, playerid);
SendClientMessage(giveplayerid, COLOR_GREEN, string);
PlayerPlaySound(playerid,1084,0.0,0.0,0.0);
printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
}
else
{
SendClientMessage(playerid, COLOR_RED, "Jou dont have so much ;)");
}
}
else
{
format(string, sizeof(string), "%d not found.", giveplayerid);
SendClientMessage(playerid, COLOR_RED, string);
}
return 1;
}