Simple question and help needed - 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: Simple question and help needed (
/showthread.php?tid=631153)
Simple question and help needed -
1fret - 24.03.2017
Ok i want this coding to work like this: if the player is admin or rcon admin they are able to use swear words in main chat but if they r not admins then it should return a message saying "You are not allowed to se swaer words in main chat"
PHP код:
// my coding
for(new words; words<sizeof(SwearWords); words++)
{
if(!IsPlayerAdmin(playerid) && pInfo[playerid][Admin] != 1)//isnt this line saying , if the player isn't rcon OR server admin it should return the message below?
{
if(strfind(text,SwearWords[words],true) != -1 )
{
SendClientMessage(playerid, error,"AdmCmd: You are not allowed to use those words here.");
return 0;
}
}
}
Re: Simple question and help needed -
AndySedeyn - 24.03.2017
Instead of checking whether the admin level isn't equal to 1, you should really check if it's equal to 0 (or less than 1). Furthermore, instead of checking whether the player is an admin with ever iteration, you can do the check outside the for-loop; this will then only start the loop if necessary (player's not an admin):
PHP код:
if(!IsPlayerAdmin(playerid) && pInfo[playerid][Admin] < 1) {
for(new words; words != sizeof(SwearWords); words++) {
if(strfind(text, SwearWords[words], true) != -1) {
SendClientMessage(playerid, error, "AdmCmd: You are not allowed to use those words here.");
return 0;
}
}
}
Re: Simple question and help needed -
SyS - 24.03.2017
I wouldn't play in a server where admins can use swear words...
Re: Simple question and help needed -
jasperschellekens - 24.03.2017
I would do it like this:
Код:
if(strfind(text, "Fuck", true) != -1 || strfind(text, "Pussy", true) != -1 || strfind(text, "Asshole", true) != -1 ||
strfind(text, "Bitch", true) != -1 || strfind(text, "Madafakker", true) != -1|| strfind(text, "Motherfucker", true) != -1 || strfind(text, "fucker", true) != -1)
{
if(pInfo[playerid][Admin] < 1)
{
return SendClientMessage(playerid, error,"You are not allowed to use those words here.");
}else return 0;
}
Edit:
In your case:
Код:
if(strfind(text,SwearWords[words],true) != -1 )
{
if(pInfo[playerid][Admin] < 1)
{
return SendClientMessage(playerid, error,"You are not allowed to use those words here.");
}else return 0;
}