Quick command
#1

Well I haven't really looked into this but I've been trying to make a /pay command using a item I created.

Well I can't really get it correct if someone could please help me that'd be awesome.

PlayerInfo[playerid][jChips] is what I'm trying to use for the pay command.
Reply
#2

Here is an example using zcmd and sscanf:

pawn Код:
CMD:pay(playerid, params[])
{
    new
        PlayerID, Chips;
    if ( sscanf ( params, "ri", PlayerID, Chips ) ) return SendClientMessage( playerid, -1, #Usage /pay <playername/id> <ammount> );
    if ( PlayerID == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, #Player offline );
    if ( Chips > PlayerInfo[ playerid ][ jChips ] ) return SendClientMessage( playerid, -1, #You dont have that much );
    PlayerInfo[ playerid ][ jChips ] -= Chips;
    SendClientMessage( playerid, -1, #You have sent some chips );
    PlayerInfo[ PlayerID ][ jChips ] += Chips;
    SendClientMessage( PlayerID, -1, #You have recieved some chips );
    return ( true );
}
Reply
#3

I fixed the command but it seemed to not work, is it possible you could make it a strcmp for me?
Reply
#4

Quote:
Originally Posted by Oh
Посмотреть сообщение
I fixed the command but it seemed to not work, is it possible you could make it a strcmp for me?
Here ya Go.

pawn Код:
if(strcmp(cmd, "/pay", true) == 0)
{
    new
        PlayerID, Chips;
    if ( sscanf ( params, "ri", PlayerID, Chips ) ) return SendClientMessage( playerid, -1, #Usage /pay <playername/id> <ammount> );
    if ( PlayerID == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, #Player offline );
    if ( Chips > PlayerInfo[ playerid ][ jChips ] ) return SendClientMessage( playerid, -1, #You dont have that much );
    PlayerInfo[ playerid ][ jChips ] -= Chips;
    SendClientMessage( playerid, -1, #You have sent some chips );
    PlayerInfo[ PlayerID ][ jChips ] += Chips;
    SendClientMessage( PlayerID, -1, #You have recieved some chips );
    return ( true );
}
Reply
#5

And not in sscanf? For some reason it fucked up my server the first time and made it so none of my commands worked. sscanf does not like my script. and PlayerID and playerid doesn't matter if you change the capitalization it's still the same thing I thought? So I made it playerid2 and PlayerID.

Quote:

error 017: undefined symbol "playerid2"
error 017: undefined symbol "ammount"

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)