#1

Getting this error:
Код:
[17:34:41] sscanf warning: Strings without a length are deprecated, please add a destination size.
[17:34:44] sscanf warning: Strings without a length are deprecated, please add a destination size.
[17:34:54] sscanf warning: Strings without a length are deprecated, please add a destination size.
[17:35:05] sscanf warning: Strings without a length are deprecated, please add a destination size.
[17:35
After i made these cmds:
Код:
CMD:slap(playerid, params[])
{
        new id, string[221], name1[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME], Float:x, Float:y, Float:z;
        if(PInfo[playerid][PlayerLevel] >= 3) { //insert your own enum here
        if(sscanf(params,"i",id)) return SendClientMessage(playerid, 0xFF000FF, "USAGE: /slap [id]");
        GetPlayerPos(id, x, y, z);
        SetPlayerPos(id, x, y, z + 10);
        GetPlayerName(playerid, name1, sizeof(name1));
        GetPlayerName(id, name2, sizeof(name2));
        format(string, sizeof(string), "{FF0000}[Admin]:{FF0000} %s {FFFFFF}has slapped{FFCC00} %s",name1,name2);
        SendClientMessageToAll(-1, string);
        } else SendClientMessage(playerid, 0xFF0000FF, "{FF0000}ERROR: Only Level 3 admins can access this.");
        return 1;
}
CMD:giveweapon(playerid, params[])
{
        new id, wep, bullet, wepname[225], string[21], name1[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
        if(PInfo[playerid][PlayerLevel] >= 3) {
        if(sscanf(params,"iii",id,wep,bullet)) return SendClientMessage(playerid, 0xFF0000FF, "{FF0000}USAGE: /giveweapon [id] [weaponid] [bullets]");
        if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000FF, "{FF0000}ERROR: Player is not connected!");
        GivePlayerWeapon(id, wep, bullet);
        GetWeaponName(wep, wepname, sizeof(wepname));
        GetPlayerName(playerid, name1, sizeof(name1));
        GetPlayerName(id, name2, sizeof(name2));
        format(string, sizeof(string), "{FF0000}[Admin]{FFFFFF}: {FF0000} %s {FFFFFF}has given {FFCC00}%s {FFFFFF}a{009900} %s(%d)!",name1,name2,wepname,bullet);
        SendClientMessageToAll(-1, string);
        } else SendClientMessage(playerid, 0xFF0000FF, "{FF0000}ERROR: Only Level 3 admins can access this.");
        return 1;
}

CMD:disarm(playerid, params[])
{
        new id, reason, name1[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME], string[221];
        if(PInfo[playerid][PlayerLevel] >= 3) {
        if(sscanf(params,"is",id,reason)) return SendClientMessage(playerid, 0xFF0000FF, "{FF0000}USAGE: /disarm [id] [reason]");
        if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000FF, "{FF0000}ERROR: Player is not connected!");
        GetPlayerName(playerid, name1, sizeof(name1));
        GetPlayerName(id, name2, sizeof(name2));
        ResetPlayerWeapons(id);
        format(string, sizeof(string), "{FF0000}[Admin]{FFFFFF}:{FF0000} %s {FFFFFF}has disarmed {FFCC00}%s.{FFFFFF} Reason: %s",name1,name2,reason);
        SendClientMessageToAll(-1, string);
        } else SendClientMessage(playerid, 0xFF0000FF, "{FF0000}ERROR: Only Level 3 admins can access this.");
        return 1;
}

CMD:explode(playerid, params[])
{
        new id, reason, name1[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME], string[221], Float:x, Float:y, Float:z;
        if(PInfo[playerid][PlayerLevel] >= 7) {
        if(sscanf(params,"is",id,reason)) return SendClientMessage(playerid, 0xFF0000FF, "{FF0000}USAGE: /explode [id] [reason]");
        if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000FF, "{FF0000}ERROR: Player is not connected!");
        GetPlayerName(playerid, name1, sizeof(name1));
        GetPlayerName(id, name2, sizeof(name2));
        GetPlayerPos(id, x, y, z);
        CreateExplosion(x, y, z, 12, 10.0);
        format(string, sizeof(string), "{FF0000}[Admin]{FFFFFF}: {FF0000}%s{FFFFFF} has exploded {FFCC00}%s. {FFCC00}Reason:{FFFFFF} %s",name1,name2,reason);
        SendClientMessageToAll(-1, string);
        } else SendClientMessage(playerid, 0xFF0000FF, "{FF0000}ERROR: Only Level 3 admins can access this.");
        return 1;
}

CMD:akill(playerid, params[])
{
        new id, reason, name1[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME], string[221];
        if(PInfo[playerid][PlayerLevel] >= 3) {
        if(sscanf(params,"is",id,reason)) return SendClientMessage(playerid, 0xFF0000FF, "{FF0000}USAGE: /akill [id] [reason]");
        if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000FF, "{FF0000}ERROR: Player is not connected!");
        GetPlayerName(playerid, name1, sizeof(name1));
        GetPlayerName(id, name2, sizeof(name2));
        SetPlayerHealth(id, 0);
        format(string, sizeof(string), "{FF0000}[Admin]{FFFFFF}: {FF0000}%s{FFFFFF} has killed {FFCC00}%s. {FFFFFF}Reason: %s",name1,name2,reason);
        SendClientMessageToAll(-1, string);
        } else SendClientMessage(playerid, 0xFF0000FF, "{FF0000}ERROR: Only Level 3 admins can access this.");
        return 1;
}
Reply
#2

Reason is an integer, not an array on both of your two last commands.

Initialize them like that "new reason[101];" (maximum reason's lenght is 100 + the nullbyte), and put the size (between the []) after the s specifier in sscanf, which should give

PHP код:

new reason[101];
if(
sscanf(params,"is[100]",id,reason)) return SendClientMessage(playerid0xFF0000FF"{FF0000}USAGE: /explode [id] [reason]"); 
Reply
#3

reason is a string so must be reason[128] and in sscanf "is[128]"
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)