SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 17/02/2018, 02:55 PM   #1
Jokers98s
Big Clucker
 
Join Date: Jul 2017
Posts: 110
Reputation: 9
Default Code not loading

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 Code:
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;

Jokers98s is offline   Reply With Quote
Old 17/02/2018, 03:03 PM   #2
Dayrion
High-roller
 
Dayrion's Avatar
 
Join Date: Jan 2016
Location: France
Posts: 1,918
Reputation: 258
Default Re: Code not loading

Why don't you use sscanf to extract player id instead of IsNumeric?
__________________
actor_plus - v5.0.2
I'm a goner, somebody catch my breath,
I'm a goner, somebody catch my breath
Dayrion is offline   Reply With Quote
Old 17/02/2018, 03:58 PM   #3
Jokers98s
Big Clucker
 
Join Date: Jul 2017
Posts: 110
Reputation: 9
Default Re: Code not loading

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;
}
Jokers98s is offline   Reply With Quote
Old 17/02/2018, 04:03 PM   #4
Abagail
High-roller
 
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,139
Reputation: 445
Default Re: Code not loading

What is CreatePlayerLabel doing? You cannot see 3D text labels attached to yourself.
Abagail is offline   Reply With Quote
Old 17/02/2018, 04:03 PM   #5
Mugala
High-roller
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 1,160
Reputation: 73
Default Re: Code not loading

dude, u're using this if(IsPlayerConnected(ofplayerid) && ofplayerid != playerid)
remove && ofplayerid != playerid <-- from code.
use this if(IsPlayerConnected(ofplayerid))
__________________
Coding in 8 languages including Pawn, C#, C++ and SQL.
Available for hiring.

If you have a coding question or need an assistance in a code, just PM me.
If you want me to create something for you, here is a Discord Mugala#5651

Currently helping Community members in a coding.
Mugala is offline   Reply With Quote
Old 18/02/2018, 03:56 AM   #6
Dayrion
High-roller
 
Dayrion's Avatar
 
Join Date: Jan 2016
Location: France
Posts: 1,918
Reputation: 258
Default Re: Code not loading

There you code wrote more cleanly

PHP Code:
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;

__________________
actor_plus - v5.0.2
I'm a goner, somebody catch my breath,
I'm a goner, somebody catch my breath
Dayrion is offline   Reply With Quote
Old 18/02/2018, 04:16 AM   #7
DobbysGamertag
Gangsta
 
DobbysGamertag's Avatar
 
Join Date: Jan 2013
Location: England
Posts: 803
Reputation: 100
Default Re: Code not loading

Just a couple of things Dayrion, IsPlayerConnected(); is useless since it checks players connected.
DobbysGamertag is offline   Reply With Quote
Old 18/02/2018, 04:35 AM   #8
Dayrion
High-roller
 
Dayrion's Avatar
 
Join Date: Jan 2016
Location: France
Posts: 1,918
Reputation: 258
Default Re: Code not loading

Quote:
Originally Posted by DobbysGamertag View Post
Just a couple of things Dayrion, IsPlayerConnected(); is useless since it checks players connected.
What check if is the player is connected?
__________________
actor_plus - v5.0.2
I'm a goner, somebody catch my breath,
I'm a goner, somebody catch my breath
Dayrion is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code not loading Jokers98s Scripting Help 5 17/02/2018 10:31 AM
Exception code crash while loading xFatality. Client Support 3 30/01/2013 09:23 PM
Loading code problem -.- RLGaming Scripting Help 11 15/10/2012 03:00 PM
Stop code from loading if... Assyria Help Archive 1 06/05/2010 03:06 PM
[HELP] Loading a code from a file? [NYRP]Mike. Help Archive 0 09/01/2010 09:00 PM


All times are GMT. The time now is 03:25 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.