Robbing another player . I get a warning
#1

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:
Code:
(1433) : warning 202: number of arguments does not match definition
Pawn code:
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;
    }
 }
pawn Code:
RandomEx(min, max) { return random(max - min) + min; }
Reply
#2

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.
Reply
#3

Quote:
Originally Posted by Lordzy
View Post
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 ?
pawn Code:
GetPlayerMoney(ID),GetPlayerMoney(ID));
? It doesn't make sence :P
Reply
#4

I'd go for:
pawn Code:
RandomEx(0, GetPlayerMoney(ID));
0 as the least value and the highest value would be player's cash.
Reply
#5

Quote:
Originally Posted by Lordzy
View Post
I'd go for:
pawn Code:
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 ?
Code:
(2171) : error 029: invalid expression, assumed zero
pawn Code:
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;
}
Reply
#6

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.
Reply
#7

PHP Code:
if(PlayerInfo[i][pAdmin] >= 1
{ // Forgot )

Lordzy beated me
Reply
#8

Quote:
Originally Posted by jihadmeneer
View Post
PHP Code:
if(PlayerInfo[i][pAdmin] >= 1
{ // Forgot )

Lordzy beated me
Ah , thanks , :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)