OnPlayerConnect problem
#1

Why my textdraw doesn't show up on OPC

PHP Code:
public OnPlayerConnect(playerid)
{
    if(
pInfo[playerid][IsBanned] == 1)
    {
        
TextDrawShowForPlayer(playeridTextdraw120);
        
TextDrawShowForPlayer(playeridTextdraw121);
        
TextDrawShowForPlayer(playeridTextdraw122);
        
TextDrawShowForPlayer(playeridTextdraw123);
        
TextDrawShowForPlayer(playeridTextdraw124);
        
TextDrawShowForPlayer(playeridTextdraw125);
    }
    return 
1;

Reply
#2

Because the account is not loaded yet, so the ban variable is still 0
Reply
#3

And there is no way to do this on player connect?
Reply
#4

Well, sure, you could load only the ban variable from the database (or File System?) and check the value like you did
Reply
#5

and what would happen if i remove this from OPC?

PHP Code:
pInfo[playerid][IsBanned] = 0
Reply
#6

This would not work.

Because if you ban someone...and he leaves the server and another player comes online, he got the playerid of the player before him. But he is not realated to this person...


So just read the saved variable.
Reply
#7

Quote:
Originally Posted by Kaliber
View Post
Well, sure, you could load only the ban variable from the database (or File System?) and check the value like you did
What do you mean by 'only'?

i have these ones too:

PHP Code:
    pInfo[playerid][Kills] = 0;
    
pInfo[playerid][Deaths] = 0;
    
pInfo[playerid][AdminLevel] = 0;
    
pInfo[playerid][LoggedIn] = 0
Reply
#8

Please help
Reply
#9

Quote:
Originally Posted by Mattski
View Post
What do you mean by 'only'?
In the login dialog you probably have a few lines which are loading the player stats, right?

He means that you copy the line from that part where it loads the "banned" variable from the player's file, and assigns it in-game, so the pBanned would actually work instead of being 0 by default when the file wasn't loaded yet.
Reply
#10

My OPC:

PHP Code:
public OnPlayerConnect(playerid)
{
    
PlayAudioStreamForPlayer(playerid"https://*******/2OInqJF");
    
SpamCount[playerid]=0;//Reset the SpamCount variable so no player can get muted wrongly after connect!
    
muted[playerid]=0;//same for mute variable!
    
pInfo[playerid][Kills] = 0;
    
pInfo[playerid][IsBanned] = 0;
    
pInfo[playerid][Deaths] = 0;
    
pInfo[playerid][AdminLevel] = 0;
    
pInfo[playerid][LoggedIn] = 0;
    
    new 
File[128],string[128];
    
format(File,sizeof(File),PLAYER_FILE,PlayerName(playerid));
    
    if(
fexist(File)) {
        if(!
strcmp(PlayerIp(playerid),dini_Get(File,"IP"),true)) {
            
GivePlayerMoney(playerid, -GetPlayerMoney(playerid) + dini_Int(File,"Money"));
            
SetPlayerScore(playeriddini_Int(File,"Score"));
            
pInfo[playerid][Kills] = dini_Int(File,"Kills");
            
pInfo[playerid][IsBanned] = dini_Int(File,"IsBanned");
            
pInfo[playerid][Deaths] = dini_Int(File,"Deaths");
            
pInfo[playerid][AdminLevel] = dini_Int(File,"AdminLevel");
            
pInfo[playerid][LoggedIn] = 1;
            
format(string,128,"{FFFFFF}[SERVER] {00CC33}You have been loggedin automaticaly {FFFFFF}[IP-MATCH] [Money: $%d | EXP: %d]",GetPlayerMoney(playerid),GetPlayerScore(playerid));
            
SendClientMessage(playeridCOLOR_GREEN,string);
        }else {
            
ShowPlayerDialog(playeridDIALOGID+2DIALOG_STYLE_INPUT"{FFFF00}Login","{00CC33}Enter your password to login:","{00CC33}Login","{CC0000}Quit");
        }
    }else {
        
ShowPlayerDialog(playeridDIALOGID+1DIALOG_STYLE_INPUT"{FFFF00}Register","{00CC33}Enter password to register:","{00CC33}Register","");
    }
    return 
1;

So, i should move this:
PHP Code:
pInfo[playerid][IsBanned] = dini_Int(File,"IsBanned"); 
OnPlayerSpawn..?
Reply


Forum Jump:


Users browsing this thread: