[Tutorial] How to make wanted level's with colors
#1

Firstly I am Very sorry for my last Tutorial Because it was very bad.

Introduction:-

Today I will teach you all how to make wanted level with colors and also a command of how to set a player's wanted level.

Requirements:-

Sscanf2 :- http://forum.sa-mp.com/showthread.ph...hlight=sscanf2
Zcmd :- https://sampforum.blast.hk/showthread.php?tid=91354

Let's Get Started:-

So first you will need to add these lines at the top.
they are includes we will use in our script
Code:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
We are done with the includes so let's make wanted levels

First to set a player's wanted level we have to put
Code:
SetPlayerWantedLevel(playerid, LEVEL);
So by our colors you can add this line where ever you need to give a player wanted level.
For now I will add it in OnPlayerSpawn Like this
Code:
public OnPlayerSpawn(playerid)
{
SetPlayerWantedLevel(playerid, Level);
return 1;
}
So level's means which level or how many starts 1 2 3 4 5 or 6.

So we will make a color pattern like this 1,2,3 = Yellow Color
4= Orange Color
5,6 = Red Color

So for the colors We need to define them like this :-
Code:
#define COLOR_YELLOW 0xFFFF00FF
#define COLOR_ORANGE 0xFFA500FF
#define COLOR_RED 0xFF0000FF
So now we have set wanted level when the player spawns

Now you need to find public OnPlayerUpdate(playerid)
If its not in your script you need to make it like this
[CODE]public OnPlayerUpdate(playerid)
{
return 1;
}/CODE]

So below OnPlayerUpdate we will add this
Code:
if(GetPlayerWantedLevel(playerid) == 0) return SetPlayerColor(playerid, -1);
if(GetPlayerWantedLevel(playerid) == 1) return SetPlayerColor(playerid, COLOR_YELLOW);
if(GetPlayerWantedLevel(playerid) == 2) return SetPlayerColor(playerid, COLOR_YELLOW);
if(GetPlayerWantedLevel(playerid) == 3) return SetPlayerColor(playerid, COLOR_YELLOW);
if(GetPlayerWantedLevel(playerid) == 4) return SetPlayerColor(playerid, COLOR_ORANGE);
if(GetPlayerWantedLevel(playerid) == 5) return SetPlayerColor(playerid, COLOR_RED);
if(GetPlayerWantedLevel(playerid) == 6) return SetPlayerColor(playerid, COLOR_RED);
Ok so here we check that if The player's Wanted level is something then set the player's color to something
You can also add your own colors but dont forget to define it

Also We need to clear the player's wanted level when he dies So Just add this in OnPlayerDeath
Code:
SetPlayerWantedLevel(playerid, 0);
So that the player gets no starts

End :-
Thank you all to read this tutorial I will be back with some awesome tutorial
Bye Guyz!
Reply
#2

No comments ?
Reply
#3

Why are you using OnPlayerUpdate for wanted levels.. Also, you should use a switch statement. And else if.
Reply
#4

I agree above.. Using onplayerupdate for wanted levels is just a little weird.. You should use it on OnPlayerDeath, that at least makes a little sense. And you could explain some more about your codes.
But he doesn't need to use else if statements, he is returning SetPlayerWantedLevel, so when something is returned, then there's no need to use else if.. except when you love typing so much that you wanna write it.
Reply
#5

You could hook the SetPlayerWantedLevel and set players color there according to their wanted level.
Reply
#6

I think it's better using this one by me :

pawn Code:
stock SetPlayerWantedLevelEx(playerid, level)
{
   switch(level)
   {
        case 0: SetPlayerColor(playerid, -1);
        case 1: SetPlayerColor(playerid, COLOR_YELLOW);
        case 2: SetPlayerColor(playerid, COLOR_YELLOW);
        case 3: SetPlayerColor(playerid, COLOR_ORANGE);
        case 4: SetPlayerColor(playerid, COLOR_DARKORANGE);
        case 5: SetPlayerColor(playerid, COLOR_RED);
        case 6: SetPlayerColor(playerid, COLOR_RED);
    }
    return SetPlayerWantedLevel(playerid, level);
}

#define SetPlayerWantedLevel SetPlayerWantedLevelEx
Reply
#7

Very bad tutorial.

Quote:
Originally Posted by iFarbod
View Post
I think it's better using this one by me :

pawn Code:
stock SetPlayerWantedLevelEx(playerid, level)
{
   switch(level)
   {
        case 0: SetPlayerColor(playerid, -1);
        case 1: SetPlayerColor(playerid, COLOR_YELLOW);
        case 2: SetPlayerColor(playerid, COLOR_YELLOW);
        case 3: SetPlayerColor(playerid, COLOR_ORANGE);
        case 4: SetPlayerColor(playerid, COLOR_DARKORANGE);
        case 5: SetPlayerColor(playerid, COLOR_RED);
        case 6: SetPlayerColor(playerid, COLOR_RED);
    }
    return SetPlayerWantedLevel(playerid, level);
}

#define SetPlayerWantedLevel SetPlayerWantedLevelEx
Just a few adjustments.

pawn Code:
stock SetPlayerWantedLevelEx(playerid, level)
{
   switch(level)
   {
        case 0: SetPlayerColor(playerid, -1);
        case 1, 2: SetPlayerColor(playerid, COLOR_YELLOW);
        case 3: SetPlayerColor(playerid, COLOR_ORANGE);
        case 4: SetPlayerColor(playerid, COLOR_DARKORANGE);
        case 5, 6: SetPlayerColor(playerid, COLOR_RED);
    }
    return SetPlayerWantedLevel(playerid, level);
}

#define SetPlayerWantedLevel SetPlayerWantedLevelEx
Reply
#8

pawn Code:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
Uhm, why did you include them while you are not using them at all?
You are not using sscanf or zcmd.
Also OnPlayerUpdate, not needed at all. You could just create OnPlayerCommitCrime or such, or just use OnPlayerDeath if you are increasing/decreasing player wanted level with deaths.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)