sscanf and zcmd.
#1

This is my code. Now if I comment the setscore command the script compiles fine. But if I have it uncommented I get this
pawn Код:
CMD:givecash(playerid, params[])
{
    new targetid, ammount;
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected.");
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "Only Administrators have access to this this command.");
    if(sscanf(params, "ui", targetid, ammount)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /givecash [id] [amount]");
    GivePlayerMoney(targetid, ammount);
    return 1;
}
CMD:setscore(playerid, params[]);
{
    new targetid, ammount;
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected.");
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "Only Administrators have access to this this command.");
    if(sscanf(params, "ui", targetid, ammount)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /givecash [id] [amount]");
    SetPlayerScore(targetid, ammount);
    return 1;
}
Код:
C:\Users\user\Desktop\h\pawno\new.pwn(216) : warning 219: local variable "targetid" shadows a variable at a preceding level
C:\Users\user\Desktop\h\pawno\new.pwn(216) : warning 219: local variable "ammount" shadows a variable at a preceding level
C:\Users\user\Desktop\h\pawno\new.pwn(224) : error 055: start of function body without function header
C:\Users\user\Desktop\h\pawno\new.pwn(226) : error 010: invalid function or declaration
C:\Users\user\Desktop\h\pawno\new.pwn(227) : error 010: invalid function or declaration
C:\Users\user\Desktop\h\pawno\new.pwn(228) : error 010: invalid function or declaration
C:\Users\user\Desktop\h\pawno\new.pwn(230) : error 010: invalid function or declaration
C:\Users\user\Desktop\h\pawno\new.pwn(232) : warning 203: symbol is never used: "ammount"
C:\Users\user\Desktop\h\pawno\new.pwn(232) : warning 203: symbol is never used: "targetid"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.
Reply
#2

Here you are

pawn Код:
CMD:givecash(playerid, params[])
{
    new targetid, ammount;
    if(sscanf(params, "ui", targetid, ammount)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /givecash [id] [amount]");
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "Only Administrators have access to this this command.");
    if( targetid != INVALID_PLAYER_ID )
    {
      GivePlayerMoney(targetid, ammount);
    }
    return 1;
}

CMD:setscore(playerid, params[])
{
    new targetid, ammount;
    if(sscanf(params, "ui", targetid, ammount)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /givecash [id] [amount]");
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "Only Administrators have access to this this command.");
    if( targetid != INVALID_PLAYER_ID )
    {
        SetPlayerScore(targetid, ammount);
    }
    return 1;
}
Also never put anything related to targetid BEFORE sscanf line
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)