PDA

View Full Version : command /givemoney


AlexuTzuBss
11/06/2018, 07:39 AM
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>");

Mike861
11/06/2018, 07:55 AM
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.)

andrejc999
11/06/2018, 07:56 AM
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?

Mike861
11/06/2018, 07:57 AM
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.

Livity
11/06/2018, 08:30 AM
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.
if(sscanf(params, "ui", giveplayerid, suma)) , SCM(playerid, COLOR_SPRINGGREEN, "/givemonney <playerid> <suma>");


Changed to:

if(sscanf(params, "ui", giveplayerid, suma)) return SCM(playerid, COLOR_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.

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


Thirdly, I have taken the time out to review and remake your code which should work perfectly.



CMD:givemoney(playerid, params[])
{
if(playerAdmin[playerid] >= 5)
{
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);
}
else return SendClientMessage(playerid, COLOR_YELLOWGREEN, "Nu esti admin!");
return 1;
}