Cant Use Chat
#8

PHP код:
public OnPlayerText(playeridtext[])
{
    new 
string[144];
    if(
text[0] == '@' && Account[playerid][Admin] >= 1)
    {
        
format(stringsizeof(string), "** |Admin Chat| %s: %s **"IsPlayerName(playerid), text[1]);
        for(new 
0GetPlayerPoolSize(); <= ji++)
        {
            if(
IsPlayerConnected(i) && Account[i][Admin] >= 1)
                
SendClientMessage(i0x0AFFC9FFstring);
        }
        return 
0;
    }
    if(
text[0] == '!' && Account[playerid][Vip] >= 1)
    {
        
format(stringsizeof(string), "~> |Vip Chat| %s: %s <~"IsPlayerName(playerid), text[1]);
        for(new 
0GetPlayerPoolSize(); <= ji++)
        {
            if(
IsPlayerConnected(i) && Account[i][Vip] >= 1)
                
SendClientMessage(i0xFF0099AAstring);
        }
        return 
0;
    }
    new var = 
GetPlayerVirtualWorld(playerid), pl_color GetPlayerColor(playerid);
    
format(stringsizeof(string), "%s (%d): {FFFFFF}%s"IsPlayerName(playerid), playeridtext);
    for(new 
0GetPlayerPoolSize(); <= ji++)
    {
        if(!
IsPlayerConnected(i) || GetPlayerVirtualWorld(i) != var) continue;
        
SendClientMessage(ipl_colorstring);
    }
    return 
0;

You were using 'return' within a loop, which would result in the loop being broken after the first iteration. (Meaning if the loop started at 0, the loop would only iterate through player ID 0 and then would not continue)

https://sampwiki.blast.hk/wiki/Control_Structures#return

Also, I've changed your loops to make use of the function 'GetPlayerPoolSize' which returns the highest player ID being used on your server.

https://sampwiki.blast.hk/wiki/GetPlayerPoolSize
Reply


Messages In This Thread
Cant Use Chat - by AfiqIqbal - 07.04.2018, 18:56
Re: Cant Use Chat - by ForCop - 07.04.2018, 19:23
Re: Cant Use Chat - by AfiqIqbal - 07.04.2018, 19:32
Re: Cant Use Chat - by ForCop - 07.04.2018, 19:39
Re: Cant Use Chat - by AdamsLT - 07.04.2018, 20:03
Re: Cant Use Chat - by AfiqIqbal - 08.04.2018, 03:23
Re: Cant Use Chat - by Mugala - 08.04.2018, 03:34
Re: Cant Use Chat - by Threshold - 08.04.2018, 03:41
Re: Cant Use Chat - by AfiqIqbal - 08.04.2018, 03:44
Re: Cant Use Chat - by Mugala - 08.04.2018, 03:50

Forum Jump:


Users browsing this thread: 1 Guest(s)