PDA

View Full Version : Robbing another player . I get a warning


Johnson_Brooks
16/05/2014, 08:18 AM
I've thought of a code but im not sure if its correct , or if it will work .
First of all here is the warning code:

(1433) : warning 202: number of arguments does not match definition


Pawn code:


CMD:robplayer(playerid,params[])
{
new
Float: pX,
Float: pY,
Float: pZ;
new pName[MAX_PLAYER_NAME];
new string[128];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
new ID;
new aName[MAX_PLAYER_NAME];
new imoney = RandomEx(GetPlayerMoney(ID)); // <====== Warning Line
GetPlayerName(ID,aName,MAX_PLAYER_NAME);
if(sscanf(params, "u", ID))
{
SendClientMessage(playerid,-1,"USAGE:: /robplayer (PlayerName/ID)");
return 1;
}
if(!IsPlayerConnected(ID))
{
SendClientMessage(playerid,-1,"The player is not connected");
return 1;
}
if(playerid == ID)
{
SendClientMessage(playerid,-1,"You cannot rob yourself");
return 1;
}
if (!IsPlayerInRangeOfPoint(playerid, 10.0, pX, pY, pZ)) return SendClientMessage(playerid,-1,"You need to be close to the player to rob him");
{
format(string,sizeof(string),"[ROBBERY] %s(%d) has robbed %s and got %d ",pName,playerid,aName,ID,imoney);
SendClientMessageToAll(COLOR_BLUE,string);
GivePlayerMoney(playerid,imoney);
GameTextForPlayer(ID, "~r~ROBBED!", 3000, 5);
format(string,sizeof(string),"[ROBBERY] %s(%d) has robbed you and got %d ",pName,playerid,imoney);
SendClientMessage(ID,COLOR_BLUE,string);
return 1;
}
}



RandomEx(min, max) { return random(max - min) + min; }

Lordzy
16/05/2014, 08:20 AM
The function "RandomEx" has got two arguments to be specified. The first one is the minimum value and the second one is the maximum value. Here you must set the maximum value to the amount of cash player got and the minimum could be lower than that or 0.

Johnson_Brooks
16/05/2014, 08:26 AM
The function "RandomEx" has got two arguments to be specified. The first one is the minimum value and the second one is the maximum value. Here you must set the maximum value to the amount of cash player got and the minimum could be lower than that or 0.

Ah , i see .
But how should i make it ? GetPlayerMoney(ID),GetPlayerMoney(ID)); ? It doesn't make sence :P

Lordzy
16/05/2014, 08:28 AM
I'd go for:

RandomEx(0, GetPlayerMoney(ID));

0 as the least value and the highest value would be player's cash.

Johnson_Brooks
16/05/2014, 08:38 AM
I'd go for:

RandomEx(0, GetPlayerMoney(ID));

0 as the least value and the highest value would be player's cash.


Ah , thanks , but getting a bit of cash instead of none is better :S .
Anyways i've got one more question :
How can i fix this one too ?
(2171) : error 029: invalid expression, assumed zero

CMD:admin(playerid, params[])
{
new string[128];
new sName[MAX_PLAYER_NAME];
new Message[128];
if(sscanf(params, "s", string)) return SendClientMessage(playerid, -1, "USAGE: /admin [question]");
GetPlayerName(playerid, sName, sizeof(sName));
format(Message, sizeof(Message), "[{FF0000}QUESTION{EEEEEE}] from %s: %s", sName, string);
for(new i; i < MAX_PLAYERS; i++){
if(PlayerInfo[i][pAdmin] >= 1 { // <======== Error line .
SendClientMessage(i,COLOR_YELLOW, Message);
}
}
return 1;
}

Lordzy
16/05/2014, 08:40 AM
When you're opening any kind of bracket, it's necessary to close them. Check carefully, at the end of that line you haven't closed the "(" bracket which was opened at that same line.

jihadmeneer
16/05/2014, 08:40 AM
if(PlayerInfo[i][pAdmin] >= 1) { // Forgot )

Lordzy beated me :(

Johnson_Brooks
16/05/2014, 08:41 AM
if(PlayerInfo[i][pAdmin] >= 1) { // Forgot )

Lordzy beated me :(

Ah , thanks , :P