Simple question and help needed
#1

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 wordswords<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) != -)
            {
                  
SendClientMessage(playeriderror,"AdmCmd: You are not allowed to use those words here.");
                return 
0;
                }
        }
    } 
Reply
#2

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 
wordswords != sizeof(SwearWords); words++) {
        if(
strfind(textSwearWords[words], true) != -1) {
            
SendClientMessage(playeriderror"AdmCmd: You are not allowed to use those words here.");
            return 
0;
        }
    }

Reply
#3

I wouldn't play in a server where admins can use swear words...
Reply
#4

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


Forum Jump:


Users browsing this thread: 1 Guest(s)