givemoney - 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: givemoney (
/showthread.php?tid=493955)
givemoney -
MatriXgaMer - 10.02.2014
Hey, i made my give money command and it gives no errors but when i type '/givemoney 1(playerid) 1(Ammount)' it gives him 49$ and when i type 2 it gives him 50$.
My code:
pawn Код:
CMD:givemoney(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] == 1 || IsPlayerAdmin(playerid))
{
new pID, kolicina;
if(sscanf(params, "us", pID, kolicina))return SendClientMessage(playerid, -1, ""BOJA_PLAVA"[Info]"BOJA_BELA" Pravilan Sintaks: /givemoney [DeoImena/ID] [Kolicina].");
if(pID == INVALID_PLAYER_ID)return SendClientMessage(playerid, -1, ""BOJA_PLAVA"[Info]"BOJA_BELA" Igrac nije pronadjen ili nije konektovan.");
new string[128], string2[128];
new ime_igraca[MAX_PLAYER_NAME];
GetPlayerName(playerid, ime_igraca, sizeof(ime_igraca));
format(string, sizeof (string), ""BOJA_CRVENA"[Novac]"BOJA_BELA" Admin %s vam je dao %d$.", ime_prezime(playerid), kolicina);
format(string2, sizeof (string2), ""BOJA_CRVENA"[Novac]"BOJA_BELA" Dali ste igracu %s %d$.", ime_igraca, kolicina);
SendClientMessage(pID, -1, string);
SendClientMessage(playerid, -1, string2);
GivePlayerMoney(pID, kolicina);
}
else
{
SendClientMessage(playerid, -1, ""BOJA_PLAVA"[Info]"BOJA_BELA" Niste ovlasceni da koristite ovu komandu.");
}
return 1;
}
Re: givemoney -
FalconX - 10.02.2014
Money is an amount. You are using string instead of an integer. Replace the following:
pawn Код:
if(sscanf(params, "us", pID, kolicina))return SendClientMessage(playerid, -1, ""BOJA_PLAVA"[Info]"BOJA_BELA" Pravilan Sintaks: /givemoney [DeoImena/ID] [Kolicina].");
With
pawn Код:
if(sscanf(params, "ui", pID, kolicina))return SendClientMessage(playerid, -1, ""BOJA_PLAVA"[Info]"BOJA_BELA" Pravilan Sintaks: /givemoney [DeoImena/ID] [Kolicina].");
You can either use
i or
d because
kolicina is not a string but integer.
Re: givemoney -
Konstantinos - 10.02.2014
FalconX said the fix for your problem but I'm going to tell you why it gave 49 and 50.
You used specifier "s" without size so the size was by default 32. You enter 1 which the character '1' is number 49 and character '2' is number 50.