SetPlayerColor 2 questions -
Stu1 - 25.10.2012
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(playerid, RED);
new Text3D:wanted = Create3DTextLabel("WANTED",RED, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(wanted, playerid, 0.0, 0.0, 0.4);
}
else
{
SetPlayerColor(playerid, ORANGE);
}
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.
Re: SetPlayerColor 2 questions -
Catalyst- - 25.10.2012
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.
Re: SetPlayerColor 2 questions -
Stu1 - 25.10.2012
Hi again, this is updated code
PHP код:
public OnPlayerUpdate(playerid)
{
wanted = Create3DTextLabel("WANTED",0xFF0000FF, 30.0, 40.0, 50.0, 40.0, 0);
for (new checkwanted; checkwanted < MAX_PLAYERS; checkwanted++)
if(gTeam[playerid] == POLICE)
if(GetPlayerWantedLevel(checkwanted) >= 1)
{
Attach3DTextLabelToPlayer(wanted, checkwanted, 0.0, 0.0, 0.4);
SetPlayerMarkerForPlayer(playerid, checkwanted, 0xFF0000FF);
}
else if(GetPlayerWantedLevel(checkwanted) == 0)
{
SetPlayerMarkerForPlayer(playerid, checkwanted, ORANGE);
}
return 1;
}
Compiles fine, and changes marker colour, however the WANTED 3dtext does not show.
Re: SetPlayerColor 2 questions -
Catalyst- - 25.10.2012
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.
Re: SetPlayerColor 2 questions -
Stu1 - 25.10.2012
Yes, it works however i want it to only show wanted players to my police class
Re: SetPlayerColor 2 questions -
Stu1 - 26.10.2012
Anyone else help me with this? (sorry if i'm bumping too early)
Re: SetPlayerColor 2 questions -
Catalyst- - 26.10.2012
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.