OnPlayerText Errors -
TheBeastKhan - 29.05.2018
This is my OnPlayerText Codes!
Код:
public OnPlayerText(playerid, text[])
{
if(playerData[playerid][playerLoggedIn])
{
if (playerData[playerid][playerScore] < 4)
{
TextDrawSetString(chat, "You need to have atleast 5 score to chat!");
TextDrawHideForPlayer(playerid, chat);
TextDrawShowForPlayer(playerid, chat);
SetTimerEx("chat1", 3000, false, "i", playerid);
return 0;
}
if(text[0] == '@' && playerData[playerid][playerLevel] >= 1)
{
new string[128];
GetPlayerName(playerid, string, sizeof(string));
format(string, sizeof(string), "{47476B}[Admin Chat] {FFFFFF}%s: %s", string, text[1]);
adminchat(COLOR_WHITE, string);
return 0;
}
else if(text[0] == '#' && playerData[playerid][playerHelper] == 1)
{
new string[128];
GetPlayerName(playerid, string, sizeof(string));
format(string, sizeof(string), "{A5DF00}[Helper Chat] {FFFFFF}%s: %s", string, text[1]);
helperchat(COLOR_WHITE, string);
return 0;
}
else
{
if (playerData[playerid][playerMuteTime] != 0)
{
new message[128];
format(message, sizeof(message), "{FFDC2E}[MUTED] {FFFFFF}You are muted for another {FFDC2E}%i {FFFFFF}seconds and cannot talk!", playerData[playerid][playerMuteTime]);
SendClientMessage(playerid, COLOR_WHITE, message);
return 0;
}
else
{
if (FindIP(text))
{
SendClientMessage(playerid, COLOR_WHITE, "{FFDC2E}[SPAM] {FFFFFF}Advert detected! If this occurs frequently, you will be kicked.");
playerData[playerid][adDetected]++;
new administratorAlert[256];
format(administratorAlert, sizeof(administratorAlert), "{C73E3E}[ADVERTISING] {FFFFFF}%s(%d): %s", playerData[playerid][playerNamee], playerid, text);
adminchat(COLOR_WHITE, administratorAlert);
if (playerData[playerid][adDetected] == 2)
{
// Kick
KickWithMessage(playerid, "You have been kicked for advertising.");
}
return 0;
}
if(strfind(text, "asshole", true) != -1 || strfind(text, "fuck", true) != -1 || strfind(text, "fucker", true) != -1 || strfind(text, "fuk", true) != -1 || strfind(text, "bitch", true) != -1 || strfind(text, "assfuck", true) != -1)
{
SendClientMessage(playerid, COLOR_WHITE, "{FFDC2E}[ABUSE] {FFFFFF}Please donot abuse.");
return 0;
}
if (playerData[playerid][messageCount] != 3)
{
new tag[400], color[20], i = playerData[playerid][playerGang];
switch(playerData[playerid][playerClass])
{
case 0, 6, CLASS_FIREFIGHTER:
{
if(playerData[playerid][playerWantedLevel] == 0)
{
if (playerData[playerid][vipColour])
{
color = "58D3F7";
}
else
{
if(playerData[playerid][playerClass] == CLASS_MEDIC)
{
// Medic Colour
color = "F78181";
}
else if(playerData[playerid][playerClass] == CLASS_FIREFIGHTER)
{
color = "9C3D36";
}
else
{
color = "FFFFFF";
}
}
}
if (playerData[playerid][playerWantedLevel] >= 1)
{
// Yellow Wanted Level
color = "FFEC41";
}
if(playerData[playerid][playerWantedLevel] >= 6)
{
// Orange Wanted Level
color = "DF802D";
}
if(playerData[playerid][playerWantedLevel] >= 25)
{
// Red Wanted Level
color = "D92C3C";
}
}
case 1: // Police
{
if (playerData[playerid][vipColour])
{
color = "58D3F7";
}
else
{
color = "3E7EFF";
}
}
case 2: // FBI
{
if (playerData[playerid][vipColour])
{
color = "58D3F7";
}
else
{
color = "8F48F5";
}
}
case 3: // CIA
{
if (playerData[playerid][vipColour])
{
color = "58D3F7";
}
else
{
color = "2F205B";
}
}
case 4: // Army
{
if (playerData[playerid][vipColour])
{
color = "58D3F7";
}
else
{
color = "1C3EFF";
}
}
case 7: // Secret Service
{
if (playerData[playerid][vipColour])
{
color = "58D3F7";
}
else
{
color = "2F205B";
}
}
}
if (playerData[playerid][playerAdminDuty]) // Admin On Duty
{
color = "47476B";
}
if(gangData[i][gangID] == 5)
{
format(tag, sizeof(tag),"{%s}[BL]%s(%i): {FFFFFF}%s", color, playerData[playerid][playerNamee], playerid, text);
}
else
{
format(tag, sizeof(tag),"{%s}%s(%i): {FFFFFF}%s", color, playerData[playerid][playerNamee], playerid, text);
}
SendClientMessageToAll(COLOR_WHITE, tag);
playerData[playerid][messageCount]++;
KillTimer(playerData[playerid][spamTimer]);
playerData[playerid][spamTimer] = SetTimerEx("StopSpam", 2000, false, "i", playerid);
}
else
{
TextDrawSetString(spam, "Please don't spam!");
TextDrawHideForPlayer(playerid, spam);
TextDrawShowForPlayer(playerid, spam);
SetTimerEx("spam1", 3000, false, "i", playerid);
}
}
}
}
return 0;
}
And this is the new thing i added!
Код:
if(gangData[i][gangID] == 5)
{
format(tag, sizeof(tag),"{%s}[TAG]%s(%i): {FFFFFF}%s", color, playerData[playerid][playerNamee], playerid, text);
}
else
{
format(tag, sizeof(tag),"{%s}%s(%i): {FFFFFF}%s", color, playerData[playerid][playerNamee], playerid, text);
}
And server started giving these messages in Server Logs :-
Код:
[01:17:52] [debug] Run time error 4: "Array index out of bounds"
[01:17:52] [debug] Accessing element at negative index -1
[01:17:52] [debug] AMX backtrace:
[01:17:52] [debug] #0 0019f298 in ?? (0, 20025948) from CnR1.amx
[01:17:52] [debug] #1 00007244 in public OnPlayerText (0, 20025948) from CnR1.amx
[01:18:04] [chat] [Player]: OH YEahshhshs
[01:18:04] [debug] Run time error 4: "Array index out of bounds"
[01:18:04] [debug] Accessing element at negative index -1
[01:18:04] [debug] AMX backtrace:
[01:18:04] [debug] #0 0019f298 in ?? (0, 20025948) from CnR1.amx
[01:18:04] [debug] #1 00007244 in public OnPlayerText (0, 20025948) from CnR1.amx
[01:18:07] [part] Player has left the server (0:1)
Please anyone help me out
Re: OnPlayerText Errors -
TheBeastKhan - 29.05.2018
Please anyone help me, +REP if fixed!
Re: OnPlayerText Errors -
RxErT - 29.05.2018
PHP код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(gangData[i][gangID] == 5)
{
format(tag, sizeof(tag),"{%s}[BL]%s(%i): {FFFFFF}%s", color, playerData[playerid][playerNamee], playerid, text);
}
else
{
format(tag, sizeof(tag),"{%s}%s(%i): {FFFFFF}%s", color, playerData[playerid][playerNamee], playerid, text);
}
SendClientMessageToAll(COLOR_WHITE, tag);
}
maybe?
EDIT: btw I can't see where did you format
tag so i guess you should be formatting it like that
new tag[50];