Scanff problems.
#1

My sscanf seems to do the opposite from what i want.

Here i got 3 example cmds i made:
pawn Код:
CMD:a(playerid, params[])
{
    new string[128];
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not authorized use this command");
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /a [text]");
    format(string,sizeof(string), "%s %s: {FFFFFF}%s", ALVL(playerid), RPName(playerid), params);
    SendAdminMessage(COLOR_RED,string);
    return 1;
}
pawn Код:
CMD:makeadmin(playerid, params[])
{
    new targetid, admin, string[128];
    if(PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not authorized to use this command.");
    if(sscanf(params, "ud", targetid, admin)) return SendClientMessage(playerid, COLOR_WHITE,"Usage: /makeadmin [PlayerID][AdminLevel]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, "ERROR: That player is not in the server");
    if(PlayerInfo[playerid][pAdmin] < PlayerInfo[targetid][pAdmin]) return SendClientMessage(playerid, COLOR_WHITE, "ERROR: You cant demote/promote a higher level admin.");
    if(PlayerInfo[playerid][pAdmin] < admin) return SendClientMessage(playerid, COLOR_WHITE,"ERROR: You can't promote yourself");
    PlayerInfo[targetid][pAdmin] = admin;
    format(string, sizeof(string), "You have been made admin level %d by %s", admin,RPName(playerid));
    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
    format(string, sizeof(string), "You have made %s a admin level %d", RPName(targetid), admin);
    return 1;
}
pawn Код:
CMD:kick(playerid, params[])
{
    new targetid, string[128];
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not authorized to use this command.");
    if(sscanf(params, "us[128]", targetid, params)) return SendClientMessage(playerid, COLOR_WHITE,"Usage: /kick [PlayerID][Reason]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE,"ERROR: That player is not in the server.");
    if(PlayerInfo[playerid][pAdmin] < PlayerInfo[targetid][pAdmin]) return SendClientMessage(playerid, COLOR_WHITE, "ERROR: You can't kick a higher level admin.");
    format(string, sizeof(string), "AdmCmd: %s has kicked %s, reason: %s", RPName(playerid), RPName(targetid), params);
    SendClientMessageToAll(COLOR_TOMATO, string);
    KickWithMessage(targetid);
    return 1;
}
After typing in /kick 1 Bye! or /makeadmin 0 6 or /a hai!
Everytime i get the msg that i have set on sscanf return..
It's doing it on all my cmds that use sscanf,
Updated Sscanf, tried on linux and on windows...

Any help??
Reply
#2

use this for kick and if works then tell me i will fix those cmds

pawn Код:
CMD:kick(playerid, params[])
{
    new playerb, string[128];
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    //if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
    if(sscanf(params, "us[128]", playerb, params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /kick [playerid] [reason]");
    if(!IsPlayerConnected(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
    if(IsPlayerNPC(playerb)) return SendClientMessage(playerid, COLOR_GREY, "You can't kick NPCs out of the server.");
    if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerb][pAdmin]) return SendClientMessage(playerid, COLOR_GREY, "Player has a higher admin level than you.");
    format(string, sizeof(string), "AdmCmd: %s has kicked %s, reason: %s", RPName(playerid), RPName(playerb), params);
    SendClientMessageToAll(COLOR_LIGHTRED, string);
    Kick(playerb);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)