convert commands
#1

hello, who I convert these three commands zcmd in cmd ?
PHP код:
COMMAND:ban(playeridparams[])
{
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playeridCOLOR_RED"[SAMP-BANS]: You need to be logged in as an RCON administrator to perform this!");
    if(
sscanf(params"uis"ban_targetban_timeban_reason)) return SendClientMessage(playeridCOLOR_RED"[SAMP-BAN]: Correct usage -> /ban <player> <time (minutes)> <reason>");
    if(!
IsPlayerConnected(ban_target)) return SendClientMessage(playeridCOLOR_RED"[SAMP-BANS]: Player was not found!");
    if(
ban_time 0SendClientMessage(playeridCOLOR_RED"[SAMP-BANS]: Please input a valid ban time!");
    
format(post_stringsizeof(post_string), "action=addban&apikey="#APIKEY"&ban_user=%s&ban_reason=%s&ban_admin=%s&ban_ip=%s&ban_time=%d",names[ban_target], ban_reason, names[playerid], ips[ban_target], ban_time);
    
HTTP(playeridHTTP_POSTAPIPATHpost_string"OnBanResponse");
    
Kick(ban_target);
    return 
1;
}
COMMAND:unbanbyip(playeridparams[])
{
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playeridCOLOR_RED"[SAMP-BANS]: You need to be logged in as an RCON administrator to perform this!");
    if(
isnull(params) || strlen(params) > MAX_PLAYER_IP) return SendClientMessage(playeridCOLOR_RED"[SAMP-BANS]: Correct usage -> /unbanbyip <ip address>");
    
format(post_stringsizeof(post_string), "action=remip&apikey="#APIKEY"&ban_ip=%s", params);
    
HTTP(playeridHTTP_POSTAPIPATHpost_string"OnRemoveResponse");
    return 
1;
}
COMMAND:unbanbyname(playeridparams[])
{
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playeridCOLOR_RED"[SAMP-BANS]: You need to be logged in as an RCON administrator to perform this!");
    if(
isnull(params) || strlen(params) > MAX_PLAYER_NAME) return SendClientMessage(playeridCOLOR_RED"[SAMP-BANS]: Correct usage -> /unbanbyname <name>");
    
format(post_stringsizeof(post_string), "action=remname&apikey="#APIKEY"&ban_name=%s&expired=true", params);
    
HTTP(playeridHTTP_POSTAPIPATHpost_string"OnRemoveResponse");
    return 
1;

Reply
#2

if(strcmp("/thecommand", cmdtext, true, 10) ==0)
Reply
#3

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/ban", true) == 0)
    {
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[SAMP-BANS]: You need to be logged in as an RCON administrator to perform this!");
        if(sscanf(params, "uis", ban_target, ban_time, ban_reason)) return SendClientMessage(playerid, COLOR_RED, "[SAMP-BAN]: Correct usage -> /ban <player> <time (minutes)> <reason>");
        if(!IsPlayerConnected(ban_target)) return SendClientMessage(playerid, COLOR_RED, "[SAMP-BANS]: Player was not found!");
        if(ban_time < 0) SendClientMessage(playerid, COLOR_RED, "[SAMP-BANS]: Please input a valid ban time!");

        format(post_string, sizeof(post_string), "action=addban&apikey="#APIKEY"&ban_user=%s&ban_reason=%s&ban_admin=%s&ban_ip=%s&ban_time=%d",names[ban_target], ban_reason, names[playerid], ips[ban_target], ban_time);

        HTTP(playerid, HTTP_POST, APIPATH, post_string, "OnBanResponse");

        Kick(ban_target);
        return 1;
    }
    if(strcmp(cmdtext, "/unbanbyip", true) == 0)
    {
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[SAMP-BANS]: You need to be logged in as an RCON administrator to perform this!");
        if(isnull(params) || strlen(params) > MAX_PLAYER_IP) return SendClientMessage(playerid, COLOR_RED, "[SAMP-BANS]: Correct usage -> /unbanbyip <ip address>");

        format(post_string, sizeof(post_string), "action=remip&apikey="#APIKEY"&ban_ip=%s", params);

        HTTP(playerid, HTTP_POST, APIPATH, post_string, "OnRemoveResponse");
        return 1;
    }
    if(strcmp(cmdtext, "/unbanbyname", true) == 0)
    {
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[SAMP-BANS]: You need to be logged in as an RCON administrator to perform this!");
        if(isnull(params) || strlen(params) > MAX_PLAYER_NAME) return SendClientMessage(playerid, COLOR_RED, "[SAMP-BANS]: Correct usage -> /unbanbyname <name>");

        format(post_string, sizeof(post_string), "action=remname&apikey="#APIKEY"&ban_name=%s&expired=true", params);

        HTTP(playerid, HTTP_POST, APIPATH, post_string, "OnRemoveResponse");
        return 1;
    }
    return 0;  
}
Reply
#4

Sscanf ERROR!

Код HTML:
[15:31:57] [join] Marc_Johnson has joined the server (0:192.168.1.158)
[15:31:58] sscanf warning: Unenclosed specifier parameters are deprecated, consider using something like p<?>.
[15:31:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:31:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:32:16] RCON (In-Game): Player #0 (Marc_Johnson) has logged in.
[15:32:44] [part] Marc_Johnson has left the server (0:1)
This is the command:

Код HTML:
if(strcmp(cmdtext, "/ban", true) == 0)
    {
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[SAMP-BANS]: You need to be logged in as an RCON administrator to perform this!");
        if(sscanf(cmdtext, "uis", ban_target, ban_time, ban_reason)) return SendClientMessage(playerid, COLOR_RED, "[SAMP-BAN]: Correct usage -> /ban <player> <time (minutes)> <reason>");
        if(!IsPlayerConnected(ban_target)) return SendClientMessage(playerid, COLOR_RED, "[SAMP-BANS]: Player was not found!");
        if(ban_time < 0) SendClientMessage(playerid, COLOR_RED, "[SAMP-BANS]: Please input a valid ban time!");

        format(post_string, sizeof(post_string), "action=addban&apikey="#APIKEY"&ban_user=%s&ban_reason=%s&ban_admin=%s&ban_ip=%s&ban_time=%d",names[ban_target], ban_reason, names[playerid], ips[ban_target], ban_time);

        HTTP(playerid, HTTP_POST, APIPATH, post_string, "OnBanResponse");

        Kick(ban_target);
        return 1;
    }
Reply
#5

This is no command error i think!
Reply
#6

You have to change cmdtext to include strtok. Not sure why you want to change it to the normal style though.. This is easier to maintain and write
Reply
#7

the problem is caused by sscanf! because you have to use another way to get the parameters in the command.
Reply
#8

Maybe update your sscanf plugin?
Reply
#9

it is possible to use zcmd and normal cmd in one gamemode ?
Reply
#10

yes!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)