Help with command
#1

Hello,
I need to ask you a question!
I want to add a command like /changeprefix <prefix>, who changed your prefix to what you wrote in <prefix>
I found some code but i cant make to FS..
Here is a code:

PHP код:
if(strcmp(cmd"/changeprefix"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            if (
logged[playerid] == 1)
            {
                if(
pInfo[playerid][PREFIXlevel] > ) {
                new 
length strlen(cmdtext);
                while ((
idx length) && (cmdtext[idx] <= ' '))
                {
                    
idx++;
                }
                new 
offset idx;
                new 
result[256];
                while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
                {
                    
result[idx offset] = cmdtext[idx];
                    
idx++;
                }
                
result[idx offset] = EOS;
                if(!
strlen(result))
                {
                    
SendClientMessage(playeridCOLOR_WHITE"Използвай: /changeprefix [Prefix]");
                    return 
1;
                }
                if(
strfindresult "," true ) == -1)
                {
                       
strmid(pInfo[playerid][Prefix], (result), 0strlen((result)), 129);
                    
format(stringsizeof(string), "{FFFFFF}Ти смени своя префикс на: {9AFF00}%s{FFFFFF}.", (result));
                    
SendClientMessage(playeridCOLOR_YELLOWstring);
                }
                }
                else
                {
                   
SendClientMessage(playeridCOLOR_RED,"Нямаш необходимия левел, за да сменяш префикса си.");
                }
            }
        }
        return 
1;
    } 
If this code have a problems pls fix it, im new in pwn so can i ask you to place the .pwn! Please.
And, can only ppls with rcon have permission to use it!
Reply
#2

For the love of God use sscanf and ZCMD....

pawn Код:
new playerPrefix[MAX_PLAYERS][24];

CMD:changeprefix(playerid,params[]) {
    new prefix[24];
    if(sscanf(params,"s[24]",prefix)) return SendClientMessage(playerid,COLOR_RED,"Usage: /changeprefix [Prefix]");
    if(strlen(prefix) >= 25 || strlen(prefix) <= 0) return SendClientMessage(playerid,COLOR_RED,"Invalid prefix size");
    format(playerPrefix[playerid],sizeof(prefix),"%s",prefix);
    return true;
}
Reply
#3

Quote:
Originally Posted by TwinkiDaBoss
Посмотреть сообщение
For the love of God use sscanf and ZCMD....

pawn Код:
new playerPrefix[MAX_PLAYERS][24];

CMD:changeprefix(playerid,params[]) {
    new prefix[24];
    if(sscanf(params,"s[24]",prefix)) return SendClientMessage(playerid,COLOR_RED,"Usage: /changeprefix [Prefix]");
    if(strlen(prefix) >= 25 || strlen(prefix) <= 0) return SendClientMessage(playerid,COLOR_RED,"Invalid prefix size");
    format(playerPrefix[playerid],sizeof(prefix),"%s",prefix);
    return true;
}
I do that, but when i write /changeprefix blablabla, he says Usage: /changeprefix [Prefix]

I know my english is bad.
Reply
#4

BUMP!
Reply
#5

he means you have to download some includes wish they make making commands more easier now you are using the basic commands.
plugins requiredscanf,zcmd. just ****** them.
Reply
#6

I have them but, when i type the /changeprefix blablabla, the command dont change my prefix just says " /changeprefix [Prefix]" in red and idk how to fix it.

PHP код:
SendClientMessage(playerid,COLOR_RED,"Usage: /changeprefix [Prefix]"); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)