SA-MP Forums Archive
OnPlayerText is wrong? - 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: OnPlayerText is wrong? (/showthread.php?tid=399229)



OnPlayerText is wrong? - Lz - 13.12.2012

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


Re: OnPlayerText is wrong? - Lz - 13.12.2012

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.


Re: OnPlayerText is wrong? - DaRk_RaiN - 13.12.2012

EDIT.


Re: OnPlayerText is wrong? - [FSaF]Jarno - 13.12.2012

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


Re: OnPlayerText is wrong? - tyler12 - 13.12.2012

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


Re: OnPlayerText is wrong? - Lz - 13.12.2012

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


Re: OnPlayerText is wrong? - DaRk_RaiN - 13.12.2012

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.