SA-MP Forums Archive
Command in strcmp - 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: Command in strcmp (/showthread.php?tid=336770)



Command in strcmp - boyan96 - 23.04.2012

PHP код:
dcmd_ban(playeridparams[]) {
    new 
pName[MAX_PLAYER_NAME] , pName2[MAX_PLAYER_NAME] , targetid reason[64] , string[128] , stringbig[256] , YEAR_string[5], YearMonthDay;
    
GetPlayerName(targetidpNamesizeof(pName));\
    
GetPlayerName(playeridpName2sizeof(pName2));
    
getdate(YearMonthDay);
    if(!
IsPlayerAdmin(playerid)) return 0;
    if(
sscanf(params"us[80]"targetid ,reason))  return SendClientMessage(playeridCOLOR_WHITE"SERVER: "COL_GREEN"/ban [playerid/partofname] [reason]");
    if(!
IsPlayerConnected(targetid)) return SendClientMessage(playeridCOLOR_WHITE"SERVER: "COL_RED" Player not connected or is yourself!");
    
format(stringsizeof(string), "SERVER: "COL_RED"%s "COL_GREEN"has been banned "COL_RED"(Reason: %s)",pNamereason);
    
SendClientMessageToAll(COLOR_WHITEstring);
    
format(YEAR_stringsizeof(YEAR_string), "%d"Year);
    
strdel(YEAR_string02);
    
format(stringbigsizeof(stringbig),"~r~Reason: ~w~ %s ~n~~r~Banned By: ~w~ %s ~n~~r~Date: ~w~ %d/%d/%s",reason,pName2,MonthDateYEAR_string);
    
TextDrawSetString(Info[playerid] , stringbig);
    
TextDrawShowForPlayer(playeridInfo[playerid]);
    
TextDrawShowForPlayer(playeridBox[playerid]);
    
TextDrawShowForPlayer(playeridBannedNotice[playerid]);
    
TextDrawShowForPlayer(playeridSite[playerid]);
    
Ban(targetid);
    return 
1;

Can help me to make this command in strcmp


Re: Command in strcmp - .FuneraL. - 23.04.2012

pawn Код:
if(!strcmp(cmdtext, "/ban", true))
{
    new pName[MAX_PLAYER_NAME] , pName2[MAX_PLAYER_NAME] , targetid , reason[64] , string[128] , stringbig[256] , YEAR_string[5], Year, Month, Day;
    GetPlayerName(targetid, pName, sizeof(pName));
    GetPlayerName(playerid, pName2, sizeof(pName2));
    getdate(Year, Month, Day);
    if(!IsPlayerAdmin(playerid)) return 0;
    if(sscanf(params, "us[80]", targetid ,reason))  return SendClientMessage(playerid, COLOR_WHITE, "SERVER: "COL_GREEN"/ban [playerid/partofname] [reason]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, "SERVER: "COL_RED" Player not connected or is yourself!");
    format(string, sizeof(string), "SERVER: "COL_RED"%s "COL_GREEN"has been banned "COL_RED"(Reason: %s)",pName, reason);
    SendClientMessageToAll(COLOR_WHITE, string);
    format(YEAR_string, sizeof(YEAR_string), "%d", Year);
    strdel(YEAR_string, 0, 2);
    format(stringbig, sizeof(stringbig),"~r~Reason: ~w~ %s ~n~~r~Banned By: ~w~ %s ~n~~r~Date: ~w~ %d/%d/%s",reason,pName2,Month, Date, YEAR_string);
    TextDrawSetString(Info[playerid] , stringbig);
    TextDrawShowForPlayer(playerid, Info[playerid]);
    TextDrawShowForPlayer(playerid, Box[playerid]);
    TextDrawShowForPlayer(playerid, BannedNotice[playerid]);
    TextDrawShowForPlayer(playerid, Site[playerid]);
    Ban(targetid);
    return 1;
}
Try This.


Re: Command in strcmp - AndreT - 23.04.2012

1. "params" is not defined in a strcmp-command like that.
2. don't get the name of the target player before you have parsed it using sscanf
3. don't get the admin's name before you actually need to use it
4. you're probably showing the textdraw for the wrong player - show it to targetid instead?
5. use a command parser like zcmd, which is faster and has "params" defined for you


Re: Command in strcmp - xx360 - 23.04.2012

Just use dcmd and define this:
Код:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1