SA-MP Forums Archive
convert commands - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: convert commands (/showthread.php?tid=377202)



convert commands - Marc_Johnson - 13.09.2012

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;




AW: convert commands - BiosMarcel - 13.09.2012

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


Re: convert commands - ViruZz - 13.09.2012

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;  
}



Re: convert commands - Marc_Johnson - 13.09.2012

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;
    }



AW: convert commands - BiosMarcel - 13.09.2012

This is no command error i think!


Re: convert commands - mamorunl - 13.09.2012

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


Re: convert commands - Marc_Johnson - 13.09.2012

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


Re: convert commands - HyDrAtIc - 13.09.2012

Maybe update your sscanf plugin?


Re: convert commands - Marc_Johnson - 13.09.2012

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


AW: convert commands - BiosMarcel - 13.09.2012

yes!