Strange bug in /setmoney command.
#1

Hello guys. I made a /setmoney for my GameMode, and it worked same way in other modes/scripts, but now when i type it IG(/setmoney 0 5000), it says: You gave 5000 to .
And i don't get any money...
Same happening to /makeadmin that worked before.
Code:
pawn Код:
COMMAND:setmoney(playerid, params[])
{
    new id;
    new ammount;
    if(IsPlayerConnected(id))
    {
        if(PlayerInfo[playerid][AdminLevel] >= 3)
        {
            if(!sscanf(params, "ui", id, ammount))
            {
                if(ammount <= 10000000000)
                {
                    new string[64]; new Name[MAX_PLAYER_NAME]; new PlayerName[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, Name, sizeof(Name));
                    GetPlayerName(id, PlayerName, sizeof(PlayerName));
                    format(string, sizeof(string), "%s Has Given You %d.", Name, ammount);
                    SendClientMessage(id, COLOR_DARKGOLD, string);
                    format(string, sizeof(string), "You Gave %d Money To %s .", ammount, PlayerName);
                    SendClientMessage(playerid, COLOR_DARKGOLD, string);
                    SetPlayerMoney(id, ammount);
                    return 1;
                }
                else return SendClientMessage(playerid, COLOR_DARKGOLD, "You can't give so much");
            }
            else return SendClientMessage(playerid, COLOR_DARKGOLD, "USAGE: /setmoney [PlayerId/PartOfName] [Ammount]");
        }
        else return NotAdmin(playerid);
    }
    else return SendClientMessage(playerid, COLOR_DARKGOLD, "Player is not connected.");
}
Reply
#2

pawn Код:
SetPlayerMoney(id, ammount);
To ?
pawn Код:
GivePlayerMoney( id, ammount);
?
Reply
#3

No, this is set, not give. There is SetPlayerMoney function...
Reply
#4

Are u fkin kidding me?
pawn Код:
new amount;
?
It works like this:
pawn Код:
new Float:amount;
I think so. I had this problem too, and I though I need Float: And it worked
Reply
#5

And also,
pawn Код:
SetPlayerMoney(id, ammount);
?
Do this buddy:
pawn Код:
SetPlayerMoney(id, GetPlayerMoney(playerid) +amount);
Reply
#6

Got something else:
pawn Код:
new id;

Do this:
pawn Код:
new id = strval(params);
. It must be some of those three
Reply
#7

There is no SetPlayerMoney() function , Use

pawn Код:
GivePlayerMoney(playerid,amount);
Or if you wanna SetPlayerMoney to amount, Use

pawn Код:
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,amount);
Reply
#8

Код:
CMD:givemoney(playerid, params[])
{
	new targetid, ammount;
	if(sscanf(params,"ui", targetid, ammount)) return SendClientMessage(playerid, COLOR_YELLOW,"/givemoney [PlayerID] [Ammount]");
	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You are not authorised to use this command.");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_YELLOW,"That player is not connected to your server!");
	GivePlayerMoney(targetid, ammount);
	return 1;
}
try this for me working
without error
Reply
#9

Made from scratch -
pawn Код:
CMD:setmoney ( playerid , params [] )
{
    if ( !PlayerInfo[playerid][AdminLevel] >= 3 ) return NotAdmin(playerid);
    new id , ammount;
    if ( !IsPlayerConnected ( id ) ) return SendClientMessage ( playerid , -1 , "Invalid Player ID" ) ;
    if ( ammount < 0 || ammount > 10000000000 ) return SendClientMessage ( playerid , -1 , "You can give more than 10000000000$" ) ;
    if ( GetPlayerMoney ( playerid ) < ammount ) return SendClientMessage ( playerid , -1 , "You cant give money more than you have." ) ;
    if ( sscanf ( params , "ui" , id , ammount ) ) return SendClientMessage ( playerid , -1 , "Usage :  /setmoney [ID] [Ammount]" ) ;
    else
    {
    new IName [ MAX_PLAYER_NAME ] , PName [ MAX_PLAYER_NAME ] , Str [ 128 ] ;
    GetPlayerName ( id , IName , MAX_PLAYER_NAME ) ;
    GetPlayerName ( playerid , IName , MAX_PLAYER_NAME ) ;
    format ( Str , 128 , "%s Has Given You %d" , IName , ammount ) ;
    SendClientMessage ( id , COLOR_DARKGOLD , Str ) ;
    format ( Str , 128 , "You Gave %d Money To %s" , ammount , PName ) ;
    SendClientMessage ( playerid , COLOR_DARKGOLD , Str ) ;
    GivePlayerMoney ( id , ammount ) ;
    }
    return 1;
}
Not Tested.
Should work properly.
Reply
#10

Try This
PHP код:
CMD:setcash(playeridparams[])
{
    new 
tmp[256],tmp2[256],ammount,playerIndextmp strtok(params,Index); tmp2 strtok(params,Index);
    
player strval(tmp);
    
ammount strval(tmp2);
    if(
IsPlayerConnected(player))
    {
         if(
PlayerInfo[playerid][Adminlevel] >= 3)
           {
            if(!
strlen(tmp))
            {
                   return 
SendClientMessage(playeridCOLOR_RED"USAGE: {0ce800}/setcash {0000ff}[PlayerId/PartOfName]{ff0000} [Ammount]");// Here When You Say "PartOfName" The Player Who Use This CMD Send The 'Money' To Player Who Have ID : "0"
            
}
            if(!
strlen(tmp2))
            {
                   return 
SendClientMessage(playeridCOLOR_RED"USAGE: {0ce800}/setcash {0000ff}[PlayerId/PartOfName]{ff0000} [Ammount]");// Here When You Say "PartOfName" The Player Who Use This CMD Send The 'Money' To Player Who Have ID : "0"
            
}
            if(
ammount <= 99999999)
               {
                new 
string[64]; new Name[MAX_PLAYER_NAME]; new PlayerName[MAX_PLAYER_NAME];
                
GetPlayerName(playeridNamesizeof(Name));
                 
GetPlayerName(playerPlayerNamesizeof(PlayerName));
                
format(stringsizeof(string), "Administrator \"%s\" has set your cash to '$%d'"Nameammount);
                
SendClientMessage(playerCOLOR_GREENstring);
                   
format(stringsizeof(string), "You Gave $%d Money To \"%s\" ."ammountPlayerName);
                   
SendClientMessage(playeridCOLOR_GREENstring);
                   
SetPlayerCash(playeridammount);
               }
            else return 
SendClientMessage(playeridCOLOR_RED"You can't give so much");
        }
           else return 
SendClientMessage(playerid,COLOR_RED,"You Can't Use This Command");
    }
    else return 
SendClientMessage(playeridCOLOR_RED"Player is not connected.");
    return 
1;
}
stock SetPlayerCash(playeridcash)
{
    
GivePlayerMoney(playerid, -GetPlayerMoney(playerid));
     
GivePlayerMoney(playeridcash);
    return 
1;

Quote:

Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)