PDA

View Full Version : Colors.


CannonBolt
02/10/2016, 09:14 PM
forward WantedLevelColour(playerid);
public WantedLevelColour(playerid)
{
switch(GetPlayerWantedLevel(playerid))
{
case 0: SetPlayerColor(playerid, COLOR_WHITE);
case 1: SetPlayerColor(playerid, COLOR_PURPLE);
default: SetPlayerColor(playerid, COLOR_RED);
}

return 1;
}

Could somebody tell me why this isn't working?

i've it all ways and it still doesn't work.

MCZOFT
04/10/2016, 12:51 PM
.... give us more we'll help you more .
you're missing something

where is the stocks of SetPlayerWantedColor .. GetPlayerWanted... where r the IF conditions on your " OnPlayerUpdate "



Revise your Sctructors

EXAMPLE ....
new
a = 5;
switch (a)
{
case 1:
{
// Won't be called
}
case 2:
{
// Won't be called
}
case 5:
{
// Will be called
}
default:
{
// Won't be called
}
}


i cant do much for you just with 3 randomly Lines...

Good luck

GoldenLion
04/10/2016, 01:02 PM
.... give us more we'll help you more .
you're missing something

where is the stocks of SetPlayerWantedColor .. GetPlayerWanted... where r the IF conditions on your " OnPlayerUpdate "



Revise your Sctructors

EXAMPLE ....
new
a = 5;
switch (a)
{
case 1:
{
// Won't be called
}
case 2:
{
// Won't be called
}
case 5:
{
// Will be called
}
default:
{
// Won't be called
}
}


i cant do much for you just with 3 randomly Lines...

Good luck

First of all: http://forum.sa-mp.com/showthread.php?t=570635
Second: do you see that he uses SetPlayerColor and GetPlayerWantedLevel, which are the premade functions? Why would he need to make some custom ones?
Third: you copied the switch from SA-MP wiki lol.

forward WantedLevelColour(playerid);
public WantedLevelColour(playerid)
{
switch(GetPlayerWantedLevel(playerid))
{
case 0: SetPlayerColor(playerid, COLOR_WHITE);
case 1: SetPlayerColor(playerid, COLOR_PURPLE);
default: SetPlayerColor(playerid, COLOR_RED);
}

return 1;
}

Could somebody tell me why this isn't working?

i've it all ways and it still doesn't work.
Where do you call WantedLevelColour? Do you have a timer? Nothing seems to be wrong with your code though...

MCZOFT
04/10/2016, 01:13 PM
GoldenLion 3 words for you

Learn Algorithms First.

Then talk to me .

surely it's copied example i didn't say i wrote it . so instead of trying to be a hero , solve his problem with the information given or Quit the forum "breow"

GoldenLion
04/10/2016, 01:16 PM
GoldenLion 3 words for you

Learn Algorithms First.

Then talk to me .

surely it's copied example i didn't say i wrote it . so instead of trying to be a hero , solve his problem with the information given or Quit the forum "breow"
I am trying to help him and stop complaining about my name, watch yourself instead of disrespecting others or just don't even reply if you don't like me. If you reply again, I won't reply to you. This is not a place to act childish.

Crayder
04/10/2016, 01:18 PM
GoldenLion 3 words for you

Learn Algorithms First.

Then talk to me .

surely it's copied example i didn't say i wrote it . so instead of trying to be a hero , solve his problem with the information given or Quit the forum "breow"

Dude, just leave the fucking Scripting Help section. You aren't helping anyone. In fact, you've lied to this guy.

@CannonBolt: Ignore everything MCZOFT said. Your code is correct, as GoldenLion said. Just answer GoldenLion's question.

CannonBolt
09/10/2016, 04:50 PM
Thanks @Crayder.

1. Should i change it to a stock?
2. i place it onplayerspawn as "WantedLevelColour(playerid);"

even when i get stars my color doesn't seem to change.

azzerking
09/10/2016, 05:03 PM
May I ask where you are calling this function?

Are you calling it under OnPlayerUpdate ? Or when they do a specific action?

CannonBolt
09/10/2016, 05:06 PM
May I ask where you are calling this function?

Are you calling it under OnPlayerUpdate ? Or when they do a specific action?


2. i place it onplayerspawn as "WantedLevelColour(playerid);"

even when i get stars my color doesn't seem to change.

Putting this under OnPlayerUpdate is a bad idea.

azzerking
09/10/2016, 05:12 PM
Is the function being overridden by another function calling the same SetPlayerColor native?

CannonBolt
09/10/2016, 05:14 PM
Is the function being overridden by another function calling the same SetPlayerColor native?

Yes. but! i tried removing that,same problem

azzerking
09/10/2016, 05:18 PM
Search your script for all instances of SetPlayerColor, and start narrowing down which ones are getting called right after you spawn.

Crayder
09/10/2016, 05:26 PM
Thanks @Crayder.

1. Should i change it to a stock?
2. i place it onplayerspawn as "WantedLevelColour(playerid);"

even when i get stars my color doesn't seem to change.

There is your problem. If you are only calling it when the player spawns it will not change when the wanted level of that player changes.

You should hook SetPlayerWantedLevel and add this line to it. That will be the only time you ever need to call it! Do not call it anywhere else!

CannonBolt
09/10/2016, 06:34 PM
Ah Nice!,how to hook it exactly?

azzerking
09/10/2016, 06:39 PM
I believe Crayder was talking about something like this:


stock HOOK_SetPlayerWantedLevel( playerid, level )
{
switch( level )
{
case 0: SetPlayerColor(playerid, COLOR_WHITE);
case 1: SetPlayerColor(playerid, COLOR_PURPLE);
default: SetPlayerColor(playerid, COLOR_RED);
}

return SetPlayerWantedLevel( playerid, level );
}
#if defined _ALS_SetPlayerWantedLevel
#undef SetPlayerWantedLevel
#else
#define _ALS_SetPlayerWantedLevel
#endif

#define SetPlayerWantedLevel HOOK_SetPlayerWantedLevel


Now whenever you use SetPlayerWantedLevel, the players color will change to the right color.

CannonBolt
09/10/2016, 06:49 PM
I believe Crayder was talking about something like this:


stock HOOK_SetPlayerWantedLevel( playerid, level )
{
switch( level )
{
case 0: SetPlayerColor(playerid, COLOR_WHITE);
case 1: SetPlayerColor(playerid, COLOR_PURPLE);
default: SetPlayerColor(playerid, COLOR_RED);
}

return SetPlayerWantedLevel( playerid, level );
}
#if defined _ALS_SetPlayerWantedLevel
#undef SetPlayerWantedLevel
#else
#define _ALS_SetPlayerWantedLevel
#endif

#define SetPlayerWantedLevel HOOK_SetPlayerWantedLevel


Now whenever you use SetPlayerWantedLevel, the players color will change to the right color.

Hey thanks,Rep for you & Crayder.

CannonBolt
09/10/2016, 07:16 PM
One problem now,since this is hooked with this function it Interferes with the other colors for example my cops or blue it overwrites that and set it's color to white (0 stars.) how could i prevent this?

azzerking
09/10/2016, 07:19 PM
Here,


stock HOOK_SetPlayerWantedLevel( playerid, level )
{
if( isCivilian( playerid ) ) // Use what ever function you use or variable
{
switch( level )
{
case 0: SetPlayerColor(playerid, COLOR_WHITE);
case 1: SetPlayerColor(playerid, COLOR_PURPLE);
default: SetPlayerColor(playerid, COLOR_RED);
}
}

return SetPlayerWantedLevel( playerid, level );
}
#if defined _ALS_SetPlayerWantedLevel
#undef SetPlayerWantedLevel
#else
#define _ALS_SetPlayerWantedLevel
#endif

#define SetPlayerWantedLevel HOOK_SetPlayerWantedLevel


You will need to make changes to this if you have more issues, either check if the player is not a cop, or check if they are a civilian