SA-MP Forums Archive
Wanted Level Not Lowering - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Wanted Level Not Lowering (/showthread.php?tid=582298)



Wanted Level Not Lowering - MaxJohnson - 19.07.2015

Can someone tell me how to decrease wanted level like if i have robbed a shop and i got wanted level 6 stars after 3 minutes my wanted level will decrease to 5 and again after 3 minutes my wanted level will be 4 like every 3 minutes i loose a wanted level can anyone help me to make this system Thank you in advance you guys already helped me alot so thank you so much


AW: Wanted Level Not Lowering - Mencent - 19.07.2015

Hello!

You have to work with a timer.
Take this or anything else:
PHP код:
SetTimerEx("OnPlayerWantedTimer",60000*3,1,"i",playerid);//This have to be where the players connect
forward OnPlayerWantedTimer(playerid);
public 
OnPlayerWantedTimer(playerid)
{
    if(
GetPlayerWantedLevel(playerid) > 0)SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid)-1);
    return 
1;

SetTimerEx have to be there where the players connect.

(Sorry for my bad English!)

- Mencent


Re: Wanted Level Not Lowering - Mariciuc223 - 19.07.2015

So , when you give wanted to player you need to put a timer

Let's say that it's your rob code :

Код HTML:
#include <a_samp>
#include <ZCMD>

forward RemoveWanted(playerid);

CMD:rob(playerid, params[])
{
	// Rob code , blah blah blah .
	if(GetPlayerWantedLevel(playerid) > 0)
	    return SendClientMessage(playerid, -1, "You need to have wanted 0 to rob"); // If wanted level > 0 the command will not continue and will show that message..

	SetPlayerWantedLevel(playerid, 6); // Set player wanted level to 6
	SetTimer("RemoveWanted", 3*60000, true); // Set timer to 3 minutes
	
	return 1;
}
public RemoveWanted(playerid)
{
	if(GetPlayerWantedLevel(playerid) == 0) // If wated = 0 ..
	    return 1; // If player wanted level = 0 the function will stop there
	    
	SendClientMessage(playerid, -1, "You lose a wanted star !"); // Send a messsage
	SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) -1); // Remove a wanted star
	
	return 1;
}



AW: Wanted Level Not Lowering - Mencent - 19.07.2015

@Mariciuc223:
Always when you get a wantedlevel you start a new global timer.
You should change this way.
Look in my first post, it's above yours.

Here is a small tip: If you start a timer (SetTimer), you doesn't have to have anything in the brackets (0 parameters).
If you use SetTimerEx you have to have anything (maybe: playerid) in the brackets (parameters > 0).

Sorry for my bad English, I hope you understand me.

-> Edit:
No problem! Therefore we are here to help!


- Mencent


Re: Wanted Level Not Lowering - Mariciuc223 - 19.07.2015

@Mencent thank , i'm at beginning ... i start to script a week ago


Re: AW: Wanted Level Not Lowering - MaxJohnson - 20.07.2015

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Hello!

You have to work with a timer.
Take this or anything else:
PHP код:
SetTimerEx("OnPlayerWantedTimer",60000*3,1,"i",playerid);//This have to be where the players connect
forward OnPlayerWantedTimer(playerid);
public 
OnPlayerWantedTimer(playerid)
{
    if(
GetPlayerWantedLevel(playerid) > 0)SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid)-1);
    return 
1;

SetTimerEx have to be there where the players connect.

(Sorry for my bad English!)

- Mencent
This is working fine but it never stops please help me


Re: Wanted Level Not Lowering - Mariciuc223 - 20.07.2015

What mean it never stop ?


Re: Wanted Level Not Lowering - MaxJohnson - 20.07.2015

Quote:
Originally Posted by Mariciuc223
Посмотреть сообщение
What mean it never stop ?
if my wanted level goes to 0 it still lowering my wanted levels how to stop it if we reach wanted level 0 then it stop works


Re: Wanted Level Not Lowering - 1nspire - 20.07.2015

Код:
CMD:rob(playerid, params[])
{
	// Rob code , blah blah blah .
	if(GetPlayerWantedLevel(playerid) > 0)
	    return SendClientMessage(playerid, -1, "You need to have wanted 0 to rob"); // If wanted level > 0 the command will not continue and will show that message..

	SetPlayerWantedLevel(playerid, 6); // Set player wanted level to 6
	wanted[playerid] = SetTimerEx("removewanted", 3*6000, true, "i", playerid); // Set timer to 3 minutes
	
	return 1;
}
public RemoveWanted(playerid)
{
	if(GetPlayerWantedLevel(playerid) == 0) // If wanted = 0 ..
	return KillTimer(wanted[playerid]);
	else   
	SendClientMessage(playerid, -1, "You lose a wanted star !"); // Send a messsage
	SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) -1); // Remove a wanted star
	
	return 1
;
}


AW: Re: AW: Wanted Level Not Lowering - Mencent - 20.07.2015

Quote:
Originally Posted by MaxJohnson
Посмотреть сообщение
This is working fine but it never stops please help me
Well this timer stops when the player is going offline. You shouldn't stop the timer when the player has 0 wanteds, because the player can get wanted again, and then the timer is off.

But, you should do this:
PHP код:
SetTimerEx("OnPlayerWantedTimer",60000*3,1,"i",playerid);//This have to be where the players connect 
to:

PHP код:
new WantedTimer[MAX_PLAYERS];//global
WantedTimer[playerid] = SetTimerEx("OnPlayerWantedTimer",60000*3,1,"i",playerid);//This have to be where the players connect
//OnPlayerDisconnect:
KillTimer(WantedTimer[playerid]); 
So, if the player leave the server the timer will stop.

- Mencent