SetPlayerColor 2 questions
#1

Hey guys, sorry to post again in help section so soon. But...
I have this code

PHP код:
public OnPlayerUpdate(playerid)
{
    if(
gTeam[playerid] == VAN)
    if(
GetPlayerWantedLevel(playerid) >= 1)
    {
    
SetPlayerColor(playeridRED);
    new 
Text3D:wanted Create3DTextLabel("WANTED",RED30.040.050.040.00);
    
Attach3DTextLabelToPlayer(wantedplayerid0.00.00.4);
    }
    else
    {
    
SetPlayerColor(playeridORANGE);
    }
    return 
1;

1. I have a fine command, but when i put DeletePlayer3DTextLabel(pId, wanted); I get an error
Код:
C:\Users\laptop.laptop-PC\Downloads\samp03e_svr_R2_win32 - Copy\gamemodes\Gamemode.pwn(2746) : error 017: undefined symbol "wanted"
2. Is there anyway the color change will only change for gTeam = POLICE ? So team VAN cannot see the colour change.

Thanks guys.
Reply
#2

pawn Код:
new Text3D:wantedLabel[MAX_PLAYERS],
    wanted[MAX_PLAYERS];

public OnPlayerUpdate(playerid)
{
    if(gTeam[playerid] == VAN)
    {
        if(GetPlayerWantedLevel(playerid) >= 1 && wanted[playerid] == 0)
        {
            SetPlayerColor(playerid, RED);
            wantedLabel[playerid] = Create3DTextLabel("WANTED",RED, 30.0, 40.0, 50.0, 40.0, 0);
            wanted[playerid] = 1;
            Attach3DTextLabelToPlayer(wantedLabel[playerid], playerid, 0.0, 0.0, 0.4);
        }
        else
        {
            SetPlayerColor(playerid, ORANGE);
        }
    }
    return 1;
}
And for deleting it:
pawn Код:
Delete3DTextLabel(wantedLabel[playerid]);
wanted = 0;
Also, I recommend that you change to a timer with at least a 1 second interval instead of using OnPlayerUpdate. You don't need to check as often as this.
Reply
#3

Hi again, this is updated code
PHP код:
public OnPlayerUpdate(playerid)
{
    
wanted Create3DTextLabel("WANTED",0xFF0000FF30.040.050.040.00);
    for (new 
checkwantedcheckwanted MAX_PLAYERScheckwanted++)
    if(
gTeam[playerid] == POLICE)
    if(
GetPlayerWantedLevel(checkwanted) >= 1)
    {
    
Attach3DTextLabelToPlayer(wantedcheckwanted0.00.00.4);
    
SetPlayerMarkerForPlayer(playeridcheckwanted0xFF0000FF);
    }
    else if(
GetPlayerWantedLevel(checkwanted) == 0)
    {
    
SetPlayerMarkerForPlayer(playeridcheckwantedORANGE);
    }
    return 
1;

Compiles fine, and changes marker colour, however the WANTED 3dtext does not show.
Reply
#4

All of the code that I wrote works fine, I've just tested it. The only thing that I removed to test it was the top and second if statement. Go ahead and try only what I posted, and see if that works for you. If not, remove the if statements one at a time until it does, then you will know where your problem is.

By the way, I'm not sure why you removed the variable that defines whether or not a player is wanted, because without it, it will just keep on creating new text labels and attaching the new one over and over.
Reply
#5

Yes, it works however i want it to only show wanted players to my police class
Reply
#6

Anyone else help me with this? (sorry if i'm bumping too early)
Reply
#7

pawn Код:
new PlayerText3D:wantedLabel[MAX_PLAYERS];
public OnPlayerUpdate(playerid)
{
    for(new aCop = 0; aCop < MAX_PLAYERS; aCop++)
    {
        if(gTeam[aCop] == POLICE)
        {
            wantedLabel[playerid] = CreatePlayer3DTextLabel(aCop, "WANTED", 0xFF0000FF, 0, 0, 0.4, 40.0, playerid);
            if(GetPlayerWantedLevel(playerid) >= 1)
                SetPlayerMarkerForPlayer(aCop, playerid, 0xFF0000FF);
            else if(GetPlayerWantedLevel(playerid) == 0)
                SetPlayerMarkerForPlayer(aCop, playerid, ORANGE);
        }
    }
    return 1;
}
This should work, though I'm unable to test it, as I'm only one person.
Though it will create the label over and over, but I'm not here to do everything for you, so I'll leave that for you to fix.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)