SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 16/05/2014, 08:18 AM   #1
Johnson_Brooks
Huge Clucker
 
Join Date: Aug 2012
Location: USA/NewYork/Whitestone
Posts: 296
Reputation: 7
Default Robbing another player . I get a warning

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; }
__________________
Johnson_Brooks is offline   Reply With Quote
Old 16/05/2014, 08:20 AM   #2
Lordzy
High-roller
 
Lordzy's Avatar
 
Join Date: Mar 2012
Location: NetherRealm
Posts: 2,698
Reputation: 1177
Default Re: Robbing another player . I get a warning

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.
Lordzy is offline   Reply With Quote
Old 16/05/2014, 08:26 AM   #3
Johnson_Brooks
Huge Clucker
 
Join Date: Aug 2012
Location: USA/NewYork/Whitestone
Posts: 296
Reputation: 7
Default Re: Robbing another player . I get a warning

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
__________________
Johnson_Brooks is offline   Reply With Quote
Old 16/05/2014, 08:28 AM   #4
Lordzy
High-roller
 
Lordzy's Avatar
 
Join Date: Mar 2012
Location: NetherRealm
Posts: 2,698
Reputation: 1177
Default Re: Robbing another player . I get a warning

I'd go for:
pawn Code:
RandomEx(0, GetPlayerMoney(ID));

0 as the least value and the highest value would be player's cash.
Lordzy is offline   Reply With Quote
Old 16/05/2014, 08:38 AM   #5
Johnson_Brooks
Huge Clucker
 
Join Date: Aug 2012
Location: USA/NewYork/Whitestone
Posts: 296
Reputation: 7
Default Re: Robbing another player . I get a warning

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;
}
__________________
Johnson_Brooks is offline   Reply With Quote
Old 16/05/2014, 08:40 AM   #6
Lordzy
High-roller
 
Lordzy's Avatar
 
Join Date: Mar 2012
Location: NetherRealm
Posts: 2,698
Reputation: 1177
Default Re: Robbing another player . I get a warning

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.
Lordzy is offline   Reply With Quote
Old 16/05/2014, 08:40 AM   #7
jihadmeneer
Big Clucker
 
Join Date: Mar 2014
Posts: 69
Reputation: 58
Default Re: Robbing another player . I get a warning

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

Lordzy beated me
jihadmeneer is offline   Reply With Quote
Old 16/05/2014, 08:41 AM   #8
Johnson_Brooks
Huge Clucker
 
Join Date: Aug 2012
Location: USA/NewYork/Whitestone
Posts: 296
Reputation: 7
Default Re: Robbing another player . I get a warning

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

Lordzy beated me
Ah , thanks , :P
__________________
Johnson_Brooks is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
robbing Mustafa6155 Scripting Help 4 24/11/2012 12:07 PM
Robbing Help Vendicatori Scripting Help 14 22/09/2012 04:38 AM
help with robbing a player 13smithc Help Archive 9 08/04/2010 12:05 PM
Robbing CPs kman Help Archive 6 23/01/2010 08:52 PM


All times are GMT. The time now is 11:32 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.