On the cmd:ban command:
PlayerInfo[targetid][pBanned] = 1;
PlayerInfo[targetid][pBannedBy] = pName; // error 1
PlayerInfo[targetid][pBannedFor] = reason; //error 2
strcpy(PlayerInfo[targetid][pBannedBy], pName, MAX_PLAYER_NAME);
strcpy(PlayerInfo[targetid][pBannedFor], reason, sizeof (reason));
#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)
You can use strcat, memcpy or format for copying a string to another.
pawn Код:
pawn Код:
|
#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2) |
PlayerInfo[targetid][pBanned] = 1;
PlayerInfo[targetid][pBannedBy] = pName; // error 1
PlayerInfo[targetid][pBannedFor] = reason; //error 2
PlayerInfo[targetid][pBanned] = 1;
new text1[50],text[40];
format(text1,sizeof(text1), " %s.",pName);
PlayerInfo[targetid][pBannedBy] = text1;
format(text,sizeof(text), " %s.",reason);
PlayerInfo[targetid][pBannedBy] = text;
PHP код:
PHP код:
|
CMD:ban(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 1) return NOACCESS
new targetid, reason[128];
if(sscanf(params, "us[30]", targetid, reason)) return SendClientMessage(playerid, -1, "USAGE: /ban [id] [reason]");
if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "The player is not connected.");
new pName[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME], day, month, year, hour, minute, second, string[150];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
GetPlayerName(playerid,targetname,MAX_PLAYER_NAME);
getdate(day, month, year);
gettime(hour, minute, second);
format(string, sizeof(string), "[{FF0000}BAN{EEEEEE}]Administrator %s has banned %s for %s",pName,targetname,reason);
SendClientMessageToAll(COLOR_WHITE,string);
format(string, sizeof(string),"[{FF0000}BAN{EEEEEE}]Administrator %s has banned you for %s",pName,reason);
SendClientMessage(targetid,COLOR_WHITE,string);
SendClientMessage(targetid,COLOR_WHITE,"--------------------------------------");
SendClientMessage(targetid, COLOR_RED, "Ban Information");
format(string, sizeof(string), "Banned by: %s", pName);
SendClientMessage(targetid, COLOR_RED, string);
format(string, sizeof(string), "Banned for: %s", reason);
SendClientMessage(targetid, COLOR_RED, string);
format(string, sizeof(string), "Ban date: %d/%d/%d at %d:%d:%d.", day, month, year, hour, minute, second);
SendClientMessage(targetid, COLOR_RED, string);
SendClientMessage(targetid, COLOR_WHITE,"Please press the F8 button to take a screenshot to use it on your appeal");
SendClientMessage(targetid,COLOR_WHITE,"--------------------------------------");
PlayerInfo[targetid][pBanned] = 1;
// PlayerInfp[targetid][pBannedBy] = pName; // error lines
// PlayerInfo[targetid][pBannedFor] = reason; // error lines
SetTimerEx("BanPlayer", 200, false, "i", targetid);
return 1;
}
why re you define strcpy as strcat
he can simply stock the name and the reason without using those |
When using strcat for copying a string to another, you have to reset it first.
@Johnson_Brooks: All I see is the lines you had. Change them to those I told you and add the macro to the script. If you still you get the errors you mentioned, post the code and the errors. |
C:\Users\\Desktop\GTA SA-MP Server\gamemodes\CnR.pwn(12) : warning 201: redefinition of constant/macro (symbol "strcpy(%0,%1,%2)") C:\Users\\Desktop\GTA SA-MP Server\gamemodes\CnR.pwn(1939) : error 001: expected token: ")", but found "[" C:\Users\\Desktop\GTA SA-MP Server\gamemodes\CnR.pwn(1939) : warning 215: expression has no effect C:\Users\\Desktop\GTA SA-MP Server\gamemodes\CnR.pwn(1939) : error 001: expected token: ";", but found "]" C:\Users\\Desktop\GTA SA-MP Server\gamemodes\CnR.pwn(1939) : error 029: invalid expression, assumed zero C:\Users\Desktop\GTA SA-MP Server\gamemodes\CnR.pwn(1939) : fatal error 107: too many error messages on one line