How to change Commands " ZCMD " To ...
#1

Hello guys


i have some CMD want to change it to Normal cmd
Like
pawn Код:
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
i need change this

pawn Код:
CMD:tempban(playerid,params[])
{
    if(!TempAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"You must be admin to use this command.");
    new days,rsn[24],id,name[24];
    if(GetCurrentTempBanCount() == 24) return SendClientMessage(playerid,COLOR_RED,"Temp Ban Limit Reached.");
    if(sscanf(params, "uds[24]",id,days,rsn)) return SendClientMessage(playerid,COLOR_RED,"Usage: /tempban <PlayerID/Name> <Amount Of Days> <Reason>");
    new year,mon,d;
    getdate(year,mon,d);
    new i = GetTempBanSlot();
    new aname[24];
    GetPlayerName(playerid,aname,sizeof aname);
    GetPlayerName(id,name,sizeof name);
    format(TempBans[i][BannedName],sizeof name,"%s",name);
    TempBans[i][BannedName] = name;
    TempBans[i][UnbanDate] = d+days;
    new str[128];
    GetPlayerName(id,name,sizeof name);
    format(str,sizeof str,"%s (ID%d) has been temporary banned by Admin %s (ID:%d) (%s)",aname,playerid,name,id,rsn);
    SendClientMessage(playerid,COLOR_RED,str);
    Kick(id);
    return 1;
}

Look : Please if know how to change it and u don't hav time for make , just say to me ( How ? )


Thank you guys!!
Reply
#2

Under onplayercommand

PHP код:
if (strcmp("/tempban"cmdtexttrue10) == 0)
    {
    if(!
TempAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"You must be admin to use this command.");
    new 
days,rsn[24],id,name[24];
    if(
GetCurrentTempBanCount() == 24) return SendClientMessage(playerid,COLOR_RED,"Temp Ban Limit Reached.");
    if(
sscanf(params"uds[24]",id,days,rsn)) return SendClientMessage(playerid,COLOR_RED,"Usage: /tempban <PlayerID/Name> <Amount Of Days> <Reason>");
    new 
year,mon,d;
    
getdate(year,mon,d);
    new 
GetTempBanSlot();
    new 
aname[24];
    
GetPlayerName(playerid,aname,sizeof aname);
    
GetPlayerName(id,name,sizeof name);
    
format(TempBans[i][BannedName],sizeof name,"%s",name);
    
TempBans[i][BannedName] = name;
    
TempBans[i][UnbanDate] = d+days;
    new 
str[128];
    
GetPlayerName(id,name,sizeof name);
    
format(str,sizeof str,"%s (ID%d) has been temporary banned by Admin %s (ID:%d) (%s)",aname,playerid,name,id,rsn);
    
SendClientMessage(playerid,COLOR_RED,str);
    
Kick(id);
    return 
1;

Reply
#3

Quote:
Originally Posted by kalanerik99
Посмотреть сообщение
Under onplayercommand

PHP код:
if (strcmp("/tempban"cmdtexttrue10) == 0)
    {
    if(!
TempAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"You must be admin to use this command.");
    new 
days,rsn[24],id,name[24];
    if(
GetCurrentTempBanCount() == 24) return SendClientMessage(playerid,COLOR_RED,"Temp Ban Limit Reached.");
    if(
sscanf(params"uds[24]",id,days,rsn)) return SendClientMessage(playerid,COLOR_RED,"Usage: /tempban <PlayerID/Name> <Amount Of Days> <Reason>");
    new 
year,mon,d;
    
getdate(year,mon,d);
    new 
GetTempBanSlot();
    new 
aname[24];
    
GetPlayerName(playerid,aname,sizeof aname);
    
GetPlayerName(id,name,sizeof name);
    
format(TempBans[i][BannedName],sizeof name,"%s",name);
    
TempBans[i][BannedName] = name;
    
TempBans[i][UnbanDate] = d+days;
    new 
str[128];
    
GetPlayerName(id,name,sizeof name);
    
format(str,sizeof str,"%s (ID%d) has been temporary banned by Admin %s (ID:%d) (%s)",aname,playerid,name,id,rsn);
    
SendClientMessage(playerid,COLOR_RED,str);
    
Kick(id);
    return 
1;

LOL , if i make this i will get
pawn Код:
error 017: undefined symbol "params"
But thank you !

anyone know how ?
Reply
#4

Ok I will try to explain you:

First of all you have to put this somewhere in your script:
pawn Код:
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }
 
    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}

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 pname[MAX_PLAYER_NAME];

    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            GetPlayerName(i, pname, sizeof (pname));
            if (strcmp(pname, text[pos], true, len) == 0)
            {
                if (len == strlen(pname)) return i;
                else
                {
                    count++;
                    userid = i;
                }
            }
        }
    }
   
    if (count != 1)
    {
        if (playerid != INVALID_PLAYER_ID)
        {
            if (count) SendClientMessage(playerid, COLOR_WHITE, "Enter the full name of the user.");
            else SendClientMessage(playerid, COLOR_GREY, "No results found for the specified phrase.");
        }
        userid = INVALID_PLAYER_ID;
    }
    return userid;
}
Now go on to OnPlayerCommandText(playerid,cmdtext[]) and add this:
pawn Код:
new cmd[256],idx,tmp[256];
cmd = strtok(cmdtext,idx);
And now to transform the command:
pawn Код:
if(strcmp(cmd,"/tempban",true) == 0)
{
 if(!TempAdmin(playerid))  return SendClientMessage(playerid,COLOR_RED,"You must be admin to use this command.");
 new days,id,name[24];
    if(GetCurrentTempBanCount() == 24) return SendClientMessage(playerid,COLOR_RED,"Temp Ban Limit Reached.");
    tmp = strtok(cmdtext,idx);
    if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_RED,"Usage: /tempban <PlayerID/Name> <Amount Of Days> <Reason>");
    id = ReturnUser(tmp);
    tmp = strtok(cmdtext,idx);
    if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_RED,"Usage: /tempban <PlayerID/Name> <Amount Of Days> <Reason>");
    days = strval(tmp);
    new length = strlen(cmdtext);
    while ((idx < length) && (cmdtext[idx] <= ' '))
    {
      idx++;
    }
    new offset = idx;
    new result[128];
    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
    {
     result[idx - offset] = cmdtext[idx];
     idx++;
    }
    result[idx - offset] = EOS;
    if(!strlen(result)) return SendClientMessage(playerid,COLOR_RED,"Usage: /tempban <PlayerID/Name> <Amount Of Days> <Reason>");
    if(IsPlayerConnected(id))
    {
     new year,mon,d;
     getdate(year,mon,d);
     new i = GetTempBanSlot();
     new aname[24];
     GetPlayerName(playerid,aname,sizeof aname);
     GetPlayerName(id,name,sizeof name);
     format(TempBans[i][BannedName],sizeof name,"%s",name);
     TempBans[i][BannedName] = name;
     TempBans[i][UnbanDate] = d+days;
     new str[128];
     GetPlayerName(id,name,sizeof name);
     format(str,sizeof str,"%s (ID%d) has been temporary banned by Admin %s (ID:%d) (%s)",aname,playerid,name,id,result);
     SendClientMessage(playerid,COLOR_RED,str);
     Kick(id);
    }
 return  1;
}
Something like that , Something probably be wrong. I made it in hurry.
Just tell me if something's wrong.
Reply
#5

Quote:
Originally Posted by Aly
Посмотреть сообщение
Ok I will try to explain you:

First of all you have to put this somewhere in your script:
pawn Код:
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }
 
    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}

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 pname[MAX_PLAYER_NAME];

    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            GetPlayerName(i, pname, sizeof (pname));
            if (strcmp(pname, text[pos], true, len) == 0)
            {
                if (len == strlen(pname)) return i;
                else
                {
                    count++;
                    userid = i;
                }
            }
        }
    }
   
    if (count != 1)
    {
        if (playerid != INVALID_PLAYER_ID)
        {
            if (count) SendClientMessage(playerid, COLOR_WHITE, "Enter the full name of the user.");
            else SendClientMessage(playerid, COLOR_GREY, "No results found for the specified phrase.");
        }
        userid = INVALID_PLAYER_ID;
    }
    return userid;
}
Now go on to OnPlayerCommandText(playerid,cmdtext[]) and add this:
pawn Код:
new cmd[256],idx,tmp[256];
cmd = strtok(cmdtext,idx);
And now to transform the command:
pawn Код:
if(strcmp(cmd,"/tempban",true) == 0)
{
 if(!TempAdmin(playerid))  return SendClientMessage(playerid,COLOR_RED,"You must be admin to use this command.");
 new days,id,name[24];
    if(GetCurrentTempBanCount() == 24) return SendClientMessage(playerid,COLOR_RED,"Temp Ban Limit Reached.");
    tmp = strtok(cmdtext,idx);
    if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_RED,"Usage: /tempban <PlayerID/Name> <Amount Of Days> <Reason>");
    id = ReturnUser(tmp);
    tmp = strtok(cmdtext,idx);
    if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_RED,"Usage: /tempban <PlayerID/Name> <Amount Of Days> <Reason>");
    days = strval(tmp);
    new length = strlen(cmdtext);
    while ((idx < length) && (cmdtext[idx] <= ' '))
    {
      idx++;
    }
    new offset = idx;
    new result[128];
    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
    {
     result[idx - offset] = cmdtext[idx];
     idx++;
    }
    result[idx - offset] = EOS;
    if(!strlen(result)) return SendClientMessage(playerid,COLOR_RED,"Usage: /tempban <PlayerID/Name> <Amount Of Days> <Reason>");
    if(IsPlayerConnected(id))
    {
     new year,mon,d;
     getdate(year,mon,d);
     new i = GetTempBanSlot();
     new aname[24];
     GetPlayerName(playerid,aname,sizeof aname);
     GetPlayerName(id,name,sizeof name);
     format(TempBans[i][BannedName],sizeof name,"%s",name);
     TempBans[i][BannedName] = name;
     TempBans[i][UnbanDate] = d+days;
     new str[128];
     GetPlayerName(id,name,sizeof name);
     format(str,sizeof str,"%s (ID%d) has been temporary banned by Admin %s (ID:%d) (%s)",aname,playerid,name,id,result);
     SendClientMessage(playerid,COLOR_RED,str);
     Kick(id);
    }
 return  1;
}
Something like that , Something probably be wrong. I made it in hurry.
Just tell me if something's wrong.
I will test it , thank you !!


can u say to me where can i larn about this ?
Reply
#6

Well, I learnt about this looking through other scripts.So I don't really know.
ZCMD is better... I don't know why you wanna learn making cmds using string compare.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)