Code not loading
#1

When i use /pl i could see the stats of myself but i cant see it... and when i use /pl [id] i can see others but still cant see mine..

Plz check the code and plz help to rewrite it ? plz
PHP код:
CMD:pl(playeridparams[])
{
    new 
ofplayerid;
    if(
IsNumeric1(params))
    {
        
ofplayerid strval(params);
        if(!
IsPlayerConnected(ofplayerid)) return SendClientMessage(playerid,COLOR_RED,"[Error] Player Not Connected");
    }
    else
    {
        
ofplayerid INVALID_PLAYER_ID;
        
SendClientMessage(playerid,COLOR_RED,"[Error] Not an valid player");
    }
    if(    
IsPlayerConnected(ofplayerid) && ofplayerid != playerid)
    {
           
//destroy all labels first
        
for(new 0GetPlayerPoolSize(); <= ji++)
        {
            
DestroyPlayerLabel(playeridi);
        }
        
CreatePlayerLabel(playeridofplayerid);
        
g_LABEL_MODE[playerid] = MODE_SINGLE_PLAYER;//enable labels
    
}
    else
    {
        if(
g_LABEL_MODE[playerid] == MODE_DISABLED)//enable labels
        
{
            for(new 
0GetPlayerPoolSize(); <= ji++)
            {
                if(
IsPlayerConnected(i))
                {
                    if(
!= ofplayerid)
                       {
                        
CreatePlayerLabel(playeridi);
                    }
                }
            }
            
g_LABEL_MODE[playerid] = MODE_ENABLED;
        }
        else
//disable labels
        
{
            for(new 
0GetPlayerPoolSize(); <= ji++)
            {
                
DestroyPlayerLabel(playeridi);
            }
            
g_LABEL_MODE[playerid] = MODE_DISABLED;
        }
    }
    return 
1;

Reply
#2

Why don't you use sscanf to extract player id instead of IsNumeric?
Reply
#3

Rewrite-d still not showing own pl stats..

Quote:

CMDl(playerid, params[])
{
new targetid = playerid;
if(!sscanf(params, "u", targetid))
{
if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "ERROR: "COL_GREY"Player is not connected.");
if(IsPlayerConnected(targetid) && targetid != playerid)
{
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
DestroyPlayerLabel(playerid, i);
}
CreatePlayerLabel(playerid, targetid);
g_LABEL_MODE[playerid] = MODE_SINGLE_PLAYER;
}
}
else
{
SendClientMessage(playerid, COLOR_BLUE, "* /pl [ID] to view another player's pl.");
targetid = playerid;
if(g_LABEL_MODE[playerid] == MODE_DISABLED)
{
CreatePlayerLabel(playerid, targetid);
g_LABEL_MODE[playerid] = MODE_ENABLED;
}
else
{
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
DestroyPlayerLabel(playerid, i);
}
g_LABEL_MODE[playerid] = MODE_DISABLED;
}
}
return 1;
}

Reply
#4

What is CreatePlayerLabel doing? You cannot see 3D text labels attached to yourself.
Reply
#5

dude, u're using this if(IsPlayerConnected(ofplayerid) && ofplayerid != playerid)
remove && ofplayerid != playerid <-- from code.
use this if(IsPlayerConnected(ofplayerid))
Reply
#6

There you code wrote more cleanly

PHP код:
CMD:pl(playeridparams[]) 

    new 
ofplayerid
    if(
sscanf(params"u"ofplayerid))
        return 
SendClientMessage(playerid,COLOR_RED,"[Error] Player Not Connected");      
    if(!
IsPlayerConnected(ofplayerid))
        return 
SendClientMessage(playerid,COLOR_RED,"[Error] Not an valid player");
    if(
ofplayerid == playerid)
    {
        if(
g_LABEL_MODE[playerid] == MODE_DISABLED)//enable labels 
        

            for(new 
0GetPlayerPoolSize(); <= ji++) 
            { 
                if(
IsPlayerConnected(i)) 
                { 
                    if(
!= ofplayerid
                    { 
                        
CreatePlayerLabel(playeridi); 
                    } 
                } 
            } 
            
g_LABEL_MODE[playerid] = MODE_ENABLED
        } 
        else
//disable labels 
        

            for(new 
0GetPlayerPoolSize(); <= ji++) 
            { 
                
DestroyPlayerLabel(playeridi); 
            } 
            
g_LABEL_MODE[playerid] = MODE_DISABLED
        }     
    }
    else
    {
        
//destroy all labels first 
        
for(new 0GetPlayerPoolSize(); <= ji++) 
        { 
            
DestroyPlayerLabel(playeridi); 
        } 
        
CreatePlayerLabel(playeridofplayerid); 
        
g_LABEL_MODE[playerid] = MODE_SINGLE_PLAYER;//enable labels 
    
}
    return 
1;

Reply
#7

Just a couple of things Dayrion, IsPlayerConnected(); is useless since it checks players connected.
Reply
#8

Quote:
Originally Posted by DobbysGamertag
Посмотреть сообщение
Just a couple of things Dayrion, IsPlayerConnected(); is useless since it checks players connected.
What check if is the player is connected?
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)