GivePlayerMoney, 1 Error -
KampfMopZ - 03.12.2011
Hi Guys,
itґs just a little Command, if player types /zalhen ID Amount it should give amount(money) to ID and withdraw amount from Playerґs money
Код:
if(!strcmp(strget(cmdtext,0),"/zahlen")){
{
if(!strlen(strget(cmdtext,1)))
return
SendClientMessage(playerid,COLOR_GREY,"Benutze: /zahlen [ID] [betrag]");
new zahler[MAX_PLAYER_NAME];
new empf = strval(strget(cmdtext,1));
new betrag = strval(strget(cmdtext,2));
GivePlayerMoney(empf, betrag);
GivePlayerMoney(zahler, -betrag);
}
return 1;
}
but now i get this error:
Код:
X:\AKIMBO\DetaF\gamemodes\deta.pwn(797) : error 035: argument type mismatch (argument 1)
1 Error.
Thank you!
kampfMoPZ
Re: GivePlayerMoney, 1 Error -
English-Conceptz - 03.12.2011
id use sscanf as str is slower and also i believe you need :
PHP код:
CMD:give( playerid, params[ ] )
{
new money;
new giveplayerid [MAX_PLAYER_NAME];
if ( sscanf( params, "ui", giveplayerid, money) ) return SendClientMessage( playerid, COLOR_RED, "USAGE: {FFFF00}/give [playerid] [amount]" );
GivePlayerMoney(giveplayerid, money);
GivePlayerMoney(playerid, -money);
return 1;
}
code might be wrong but the idea is there havent tested it,
also need to include sscanf at the top of your script
and need to define the colour red

i dont no its hex value off by heart
you could also add if player doesnt have enough cash then say so or this:
PHP код:
if ( giveplayerid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, COLOR_RED, "Player Is Not Connected!" );
AW: GivePlayerMoney, 1 Error -
KampfMopZ - 03.12.2011
Uff i downt have zcmd and i dont want to change it all, can you only tell me my error?
thanks!
Re: GivePlayerMoney, 1 Error -
English-Conceptz - 03.12.2011
what line is 797 ?
need to know as i dont speak german lol
AW: GivePlayerMoney, 1 Error -
KampfMopZ - 03.12.2011
Код:
GivePlayerMoney(zahler, -betrag);
this is the error-line
KampfMOpZ
Re: GivePlayerMoney, 1 Error -
English-Conceptz - 03.12.2011
try putting a space between the minus sign and the betrag?
also check your vairables are the right type E.G interger
PHP код:
GivePlayerMoney(playerid, -betrag);
if you use the command i gave above it will work 100%
Re: GivePlayerMoney, 1 Error -
iPLEOMAX - 03.12.2011
pawn Код:
if(!strcmp(strget(cmdtext,0),"/zahlen")){
{
if(!strlen(strget(cmdtext,1)))
return
SendClientMessage(playerid,COLOR_GREY,"Benutze: /zahlen [ID] [betrag]");
new zahler[MAX_PLAYER_NAME]; //<--- This is a 'string'.
new empf = strval(strget(cmdtext,1));
new betrag = strval(strget(cmdtext,2));
GivePlayerMoney(empf, betrag);
GivePlayerMoney(zahler /* <--- This function requires an integer variable, 'zahler' is not an integer */, -betrag);
}
return 1;
}
Replace using this:
pawn Код:
GivePlayerMoney(playerid, -betrag);
And btw, to make use of the name variable:
pawn Код:
if(!strcmp(strget(cmdtext,0),"/zahlen"))
{
if(!strlen(strget(cmdtext,1)))
return SendClientMessage(playerid,COLOR_GREY,"Benutze: /zahlen [ID] [betrag]");
new names[MAX_PLAYER_NAME], message[64];
new empf = strval(strget(cmdtext,1));
new betrag = strval(strget(cmdtext,2));
GivePlayerMoney(empf, betrag);
GivePlayerMoney(playerid, -betrag);
GetPlayerName(playerid, names, sizeof names);
format(message, sizeof message, "%s hat %i$ auf Sie ьbertragen.", names, betrag);
SendClientMessage(empf, -1, message);
GetPlayerName(empf, names, sizeof names);
format(message, sizeof message, "Sie haben %i$ zu %s.", betrag, names);
SendClientMessage(playerid, -1, message);
return 1;
}
AW: GivePlayerMoney, 1 Error -
KampfMopZ - 03.12.2011
Thank you! Verry nice!