OnPlayerText is wrong?
#1

So here is my OnPlayerText Script

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(PlayerInfo[playerid][pAdmin] != 1)
    {
    new admintext[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    format(admintext, sizeof (admintext), "{00FF00}[HELPER] {FFFFFF}%s: %s", name,text);
    SendClientMessageToAll(-1, admintext);
    return 0;
    }
    if(PlayerInfo[playerid][pAdmin] != 2)
    {
    new admintext[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    format(admintext, sizeof (admintext), "{F6FF00}[MODERATOR] {FFFFFF}%s: %s", name,text);
    SendClientMessageToAll(-1, admintext);
    return 0;
    }
    if(PlayerInfo[playerid][pAdmin] != 4)
    {
    new admintext[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    format(admintext, sizeof (admintext), "{B30000}[ADMINISTRATOR] {FFFFFF}%s: %s", name,text);
    SendClientMessageToAll(-1, admintext);
    return 0;
    }
    if(PlayerInfo[playerid][pAdmin] != 5)
    {
    new admintext[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    format(admintext, sizeof (admintext), "{FF8800}[DIRECTOR] {FFFFFF}%s: %s", name,text);
    SendClientMessageToAll(-1, admintext);
    return 0;
    }
    return 1;
    }
On my register function i have

pawn Код:
PlayerInfo[playerid][pAdmin] = 0;
But whenever a player connects to my server and types, no matter what admin rank.. even if they're rank 5
it will say

Код:
[HELPER] name: blablabla
Any reason? Thanks
Reply
#2

Quote:
Originally Posted by ******
Посмотреть сообщение
Do you know what your own "if" statements mean?
I thought it means if the player is... then checks through the array to see if its the rank? :S I'm pretty new to scripting you can see.
Reply
#3

EDIT.
Reply
#4

"!=" means "Doesn't equal to", so if the player's rank DOESN'T EQUAL TO 5 he will be rank 5.
change it to ==.
Reply
#5

Use ==. It mean's equals too.
=> mean's equals or more than.
!= mean's isn't equal too that.
Reply
#6

Thank you all, I see the error i thought != was equal too D:

Quote:
Originally Posted by ******
Посмотреть сообщение
Ignore DaRk_RaiN's post, the code posted there has not been tested - which is a requirement of posting code answers here so as to not further confuse question askers. I can tell you now it is wrong.

I'd also say ignore everyone else's post if you actually want to learn something instead of just being spoon-fed answers like an idiot, but that's up to you.
And thank you for the referral, I had a quick flick through just to check the if statements for now, will read the rest later
Reply
#7

pawn Код:
public OnPlayerText(playerid, text[])
   {
    if(PlayerInfo[playerid][pAdmin] == 1)
    {
    new admintext[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    format(admintext, sizeof (admintext), "{00FF00}[HELPER] {FFFFFF}%s: %s", name,text);
    SendClientMessageToAll(-1, admintext);
    return 0;
    }
    if(PlayerInfo[playerid][pAdmin] ==2)
    {
    new admintext[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    format(admintext, sizeof (admintext), "{F6FF00}[MODERATOR] {FFFFFF}%s: %s", name,text);
    SendClientMessageToAll(-1, admintext);
    return 0;
    }
    if(PlayerInfo[playerid][pAdmin] == 4)
    {
    new admintext[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    format(admintext, sizeof (admintext), "{B30000}[ADMINISTRATOR] {FFFFFF}%s: %s", name,text);
    SendClientMessageToAll(-1, admintext);
    return 0;
    }
    if(PlayerInfo[playerid][pAdmin] == 5)
    {
    new admintext[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    format(admintext, sizeof (admintext), "{FF8800}[DIRECTOR] {FFFFFF}%s: %s", name,text);
    SendClientMessageToAll(-1, admintext);
    return 0;
    }
    return 1;
    }
I apologize for the useless code above.
This is the correct one.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)