/setskin help!! Errors [rep+]
#6

Quote:
Originally Posted by Neozftw
Посмотреть сообщение
I urgently suggest you are going to use either zcmd or y_cmd, and use sscanf for the parameters. This is much much faster, and you will get better support from everyone. You can do a simple search query to find many tutorials about these systems.
If i want to change to zcmd or y_cmd?Do i need to change all my cmds?? And Which is and better, zcmd or y_cmd??

Quote:
Originally Posted by belhot1992
Посмотреть сообщение
I usually work with sscanf so I'm not that familiar with this kind of way to do commands but I think that you actually forgot to define giveplayer.
So this is the new code.

Try now

pawn Код:
if(strcmp(cmd, "/setskin", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setskin [Playerid/PartOfName] [skin id]");
            return 1;
        }
        new para1;
        new level;
        new giveplayer[MAX_PLAYER_NAME];                       
        tmp = strtok(cmdtext, idx);
        para1 = ReturnUser(tmp);
        level = strval(tmp);
        if(level > 299 || level < 1)
        {
            SendClientMessage(playerid, COLOR_GREY, "Wrong skin ID!");
            return 1;
        }
        if (PlayerInfo[playerid][pAdmin] >= 2)
        {
            if(IsPlayerConnected(para1))
            {
                if(para1 != INVALID_PLAYER_ID)
                {
                    GetPlayerName(para1, giveplayer, sizeof(giveplayer));
                    format(string, sizeof(string), "You have set %s's skin to %d.", giveplayer,level);
                    SendClientMessage(playerid, COLOR_GRAD2, string);
                    SetPlayerSkin(para1, level);
                }
            }
        }
        else
        {
                SendClientMessage(playerid, COLOR_GRAD1, "You are not authorised to use that command.");
        }
    }
    return 1;
}
Given an error "ReturnUser undefined symbol" Thanks for the help though bro! Sscanf easy to use??

Quote:
Originally Posted by Kostas'
Посмотреть сообщение
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256],
        tmp[128],
        idx;
    if(strcmp(cmd, "/setskin", true) == 0) {
        if(IsPlayerConnected(playerid)) {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)) {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setskin [Playerid/PartOfName] [skin id]");
                return 1;
            }
            new para1,
                level,
                string[128],
                giveplayer[MAX_PLAYER_NAME];
            para1 = ReturnUser(tmp);
            tmp = strtok(cmdtext, idx);
            level = strval(tmp);
            if(level > 299 || level < 1) { SendClientMessage(playerid, COLOR_GREY, "Wrong skin ID!"); return 1; }
            if (PlayerInfo[playerid][pAdmin] >= 2) {
                if(IsPlayerConnected(para1)) {
                    if(para1 != INVALID_PLAYER_ID) {

                        GetPlayerName(para1, giveplayer, sizeof(giveplayer));
                        format(string, sizeof(string), "You have set %s's skin to %d.", giveplayer,level);
                        SendClientMessage(playerid, COLOR_GRAD2, string);
                        SetPlayerSkin(para1, level);
                    }
                }
            }
            else {
                SendClientMessage(playerid, COLOR_GRAD1, "You are not authorised to use that command.");
            }
        }
        return 1;
    }
    return 0;
}

stock ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
    new pos = 0;
    while (text[pos] < 0x21) {
        if (text[pos] == 0) return INVALID_PLAYER_ID;
        pos++;
    }
    new userid = INVALID_PLAYER_ID;
    if (IsNumeric(text[pos])) {
        userid = strval(text[pos]);
        if (userid >=0 && userid < MAX_PLAYERS) {
            if(!IsPlayerConnected(userid)) {
                userid = INVALID_PLAYER_ID;
            }
            else {
                return userid;
            }
        }
    }

    new len = strlen(text[pos]);
    new count = 0;
    new name[MAX_PLAYER_NAME];
    for (new i = 0; i < MAX_PLAYERS; i++) {
        if (IsPlayerConnected(i)) {
            GetPlayerName(i, name, sizeof (name));
            if (strcmp(name, text[pos], true, len) == 0) {
                if (len == strlen(name)) {
                    return i;
                }
                else {
                    count++;
                    userid = i;
                }
            }
        }
    }
    if (count != 1) {
        if (playerid != INVALID_PLAYER_ID) {
            if (count) {
                SendClientMessage(playerid, 0xFF0000AA, "Multiple users found, please narrow search.");
            }
            else {
                SendClientMessage(playerid, 0xFF0000AA, "No matching user found.");
            }
        }
        userid = INVALID_PLAYER_ID;
    }
    return userid;
}
IsNumeric(const string[])
{
    for (new i = 0, j = strlen(string); i < j; i++) {
        if (string[i] > '9' || string[i] < '0') return 0;
    }
    return 1;
}
Thanks alot brother. That worked! Can you explain me the usage of the functions you used? And return user?


EDIT: Which cmd system is better and easy for beginners?? zcmd/y_cmd/sscanf?


Thanks to everyone for the help! [repped+]
BMiaa
Reply


Messages In This Thread
/setskin help!! Errors [rep+] - by Ballu Miaa - 15.12.2011, 15:30
Re: /setskin help!! Errors [rep+] - by JackT - 15.12.2011, 15:37
Re: /setskin help!! Errors [rep+] - by JackT - 15.12.2011, 15:55
Re: /setskin help!! Errors [rep+] - by Kostas' - 15.12.2011, 16:04
Re: /setskin help!! Errors [rep+] - by HB - 15.12.2011, 16:11
Re: /setskin help!! Errors [rep+] - by Ballu Miaa - 16.12.2011, 02:52
Re: /setskin help!! Errors [rep+] - by Ballu Miaa - 16.12.2011, 03:08
Re: /setskin help!! Errors [rep+] - by Ballu Miaa - 16.12.2011, 03:19
Re: /setskin help!! Errors [rep+] - by Ballu Miaa - 16.12.2011, 03:24
Re: /setskin help!! Errors [rep+] - by Ballu Miaa - 16.12.2011, 03:32

Forum Jump:


Users browsing this thread: 1 Guest(s)