command /givemoney
#1

This is CMD:

CMD:givemoney(playerid, params[])
{
if(playerAdmin[playerid] > 1) return SendClientMessage(playerid, COLOR_YELLOWGREEN, "Nu esti admin!");
if(playerAdmin[playerid] < 5) return SendClientMessage(playerid, COLOR_YELLOWGREEN, "Doar adminii de nivel 5+ pot folosi aceasta comanda.");
new string[256], giveplayerid, suma, player2[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME];
GetPlayerName(giveplayerid, player2, sizeof(player2));
GetPlayerName(playerid, sendername, sizeof(sendername));
if(sscanf(params, "ui", giveplayerid, suma)), SCM(playerid, COLOR_SPRINGGREEN, "/givemonney <playerid> <suma>");
if(giveplayerid == INVALID_PLAYER_ID) return SCM(playerid, COLOR_SPRINGGREEN, "Player-ul nu este conectat!");
GivePlayerMoney(giveplayerid, suma);
format(string, sizeof(string), "Ai primit $%d de la adminul %d");
SCM(playerid, COLOR_MEDIUMMAGENTA, string);
format(string, sizeof(string), "I-ai dat player-ului %s[ID:%d] suma de $%d.", player2, giveplayerid, suma);
SCM(playerid, COLOR_MEDIUMMAGENTA, string);
return 1;
}



and error is error 029: invalid expression, assumed zero
on line : if(sscanf(params, "ui", giveplayerid, suma)), SCM(playerid, COLOR_SPRINGGREEN, "/givemonney <playerid> <suma>");
Reply
#2

Код:
CMD:givemoney(playerid, params[])
{
if(playerAdmin[playerid] > 1) return SendClientMessage(playerid, COLOR_YELLOWGREEN, "Nu esti admin!");
if(playerAdmin[playerid] < 5) return SendClientMessage(playerid, COLOR_YELLOWGREEN, "Doar adminii de nivel 5+ pot folosi aceasta comanda.");
new string[256], giveplayerid, suma, player2[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME];
GetPlayerName(giveplayerid, player2, sizeof(player2));
GetPlayerName(playerid, sendername, sizeof(sendername));
if(sscanf(params, "ui", giveplayerid, suma)) return SCM(playerid, COLOR_SPRINGGREEN, "/givemonney <playerid> <suma>");
if(giveplayerid == INVALID_PLAYER_ID) return SCM(playerid, COLOR_SPRINGGREEN, "Player-ul nu este conectat!");
GivePlayerMoney(giveplayerid, suma);
format(string, sizeof(string), "Ai primit $%d de la adminul %s",suma,sendername);
SCM(playerid, COLOR_MEDIUMMAGENTA, string);
format(string, sizeof(string), "I-ai dat player-ului %s[ID:%d] suma de $%d.", player2, giveplayerid, suma);
SCM(playerid, COLOR_MEDIUMMAGENTA, string);
return 1;
}
Try this.(I couldn't understand some parts since it's on Romanian but i hope this works.)
Reply
#3

Did you include sscanf in your script?

EDIT: What's the point of this line?:

Код:
if(playerAdmin[playerid] > 1) return SendClientMessage(playerid, COLOR_YELLOWGREEN, "Nu esti admin!");
It's basically saying that if you're an admin you can't use this command?
Reply
#4

Quote:
Originally Posted by andrejc999
Посмотреть сообщение
Did you include sscanf in your script?
He did not mention undefined sscanf include error, so i bet he has it included in his script.
Reply
#5

Your code makes no sense, hence it will result in sending an error message to the admin which tries to execute the command.


First issue:
You had a comma here which is not needed, Mike had fixed that but I don't know why he didn't change the rest of the code, or maybe he didn't see it.
PHP код:
if(sscanf(params"ui"giveplayeridsuma)) [B],[/BSCM(playeridCOLOR_SPRINGGREEN"/givemonney <playerid> <suma>"); 
Changed to:

PHP код:
if(sscanf(params"ui"giveplayeridsuma)) return SCM(playeridCOLOR_SPRINGGREEN"/givemonney <playerid> <suma>"); 
Second Issue:

I assume that this is an admin command because its just spawning the amount of cash which the person inputted. So it must be an admin command, or otherwise regular players will be able to use it.

This piece of code makes no sense, why are you checking if the player rank is greater than 1 and then sending the admin the error message that he/she is not an admin. In other words if an level 5 admin uses the command it wont work because their level is higher than 1 so it would result in them receiving the error message.

PHP код:
if(playerAdmin[playerid] > 1) return SendClientMessage(playeridCOLOR_YELLOWGREEN"Nu esti admin!");
if(
playerAdmin[playerid] < 5) return SendClientMessage(playeridCOLOR_YELLOWGREEN"Doar adminii de nivel 
Thirdly, I have taken the time out to review and remake your code which should work perfectly.

PHP код:

CMD
:givemoney(playeridparams[])
{
    if(
playerAdmin[playerid] >= 5)
    {
        new 
string[256], giveplayeridsumaplayer2[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME];
        
GetPlayerName(giveplayeridplayer2sizeof(player2));
        
GetPlayerName(playeridsendernamesizeof(sendername));
        if(
sscanf(params"ui"giveplayeridsuma)) return SCM(playeridCOLOR_SPRINGGREEN"/givemonney <playerid> <suma>");
        if(
giveplayerid == INVALID_PLAYER_ID) return SCM(playeridCOLOR_SPRINGGREEN"Player-ul nu este conectat!");
        
GivePlayerMoney(giveplayeridsuma);
        
format(stringsizeof(string), "Ai primit $%d de la adminul %s",suma,sendername);
        
SCM(playeridCOLOR_MEDIUMMAGENTAstring);
        
format(stringsizeof(string), "I-ai dat player-ului %s[ID:%d] suma de $%d."player2giveplayeridsuma);
        
SCM(playeridCOLOR_MEDIUMMAGENTAstring);
     }
     else return 
SendClientMessage(playeridCOLOR_YELLOWGREEN"Nu esti admin!");
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)