Sa-mp wont detect my wanted level?
#1

Hello.

What is going on? I just made my first tax formula and SA-MP doesn't detect the wanted level...

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	//=============[SETDEFAULT]=============//
	SetPlayerWantedLevel(playerid, 0);
	//================[TAX]================//
	new string[128];
	new wantedlevel; wantedlevel = GetPlayerWantedLevel(playerid);
	new moneyamount; moneyamount = GetPlayerMoney(playerid);
	new tax;
	
	if(moneyamount < 0) { tax = (wantedlevel*((9/10)*-moneyamount))/5-random(1000); } //so you dont get on + with the money
	if(moneyamount > 0) { tax = (wantedlevel*((9/10)*moneyamount))/5+random(1000); }
 	format(string, sizeof string, "Your total tax was %d$.", tax);
  	SendClientMessage(playerid, COLOR_ACHIEVEMENT, string);
  	GivePlayerMoney(playerid, -tax);
	return 1;
}
My wanted level will be always taken as 0.
What this means is that we get 0+random(1000) always.
eg. (0*53732) + 782 = 0+782 = 782
How do I make it so Pawno will detect the wantedlevel?
I really need the wanted level.... please help... THANKS!!!!
Reply
#2

Of course it returns 0 if you set it to 0 before? xD


//=============[SETDEFAULT]=============//
SetPlayerWantedLevel(playerid, 0);
//================[TAX]================//


pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new string[128];
    new wantedlevel; wantedlevel = GetPlayerWantedLevel(playerid);
    new moneyamount; moneyamount = GetPlayerMoney(playerid);
    new tax;
   
    if(moneyamount < 0) { tax = (wantedlevel*((9/10)*-moneyamount))/5-random(1000); } //so you dont get on + with the money
    if(moneyamount > 0) { tax = (wantedlevel*((9/10)*moneyamount))/5+random(1000); }
    format(string, sizeof string, "Your total tax was %d$.", tax);
    SendClientMessage(playerid, COLOR_ACHIEVEMENT, string);
    GivePlayerMoney(playerid, -tax);
    //=============[SETDEFAULT]=============//
    SetPlayerWantedLevel(playerid, 0);
    //================[TAX]================//
    return 1;
}
Reply
#3

What the person above me said, but also: an integer divided by another integer remains an integer. So, 9/10 will always return 0.
Reply
#4

Oh god I am motherflipping stupid! Thank you very much ! I can't believe im such an idiot...
Reply
#5

Well even removed the SetPlayerWantedLevel and it still does this... what the...? My final code:
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	//================[TAX]================//
	new string[128];
	new wantedlevel; wantedlevel = GetPlayerWantedLevel(playerid);
	new moneyamount; moneyamount = GetPlayerMoney(playerid);
	new tax;

	if(moneyamount < 0) { tax = (wantedlevel*((3/4)*-moneyamount))-random(1000); }
	if(moneyamount > 0) { tax = (wantedlevel*((3/4)*moneyamount))+random(1000); }
 	format(string, sizeof string, "Your total tax was %d$.", tax);
  	SendClientMessage(playerid, COLOR_ACHIEVEMENT, string);
  	GivePlayerMoney(playerid, -tax);
	return 1;
}
Reply
#6

Aren't you trying to get the wanted level of the killer?

Use killerid instead of playerid.

pawn Код:
new wantedlevel = GetPlayerWantedLevel(killerid);
Reply
#7

No, I am trying to get the wanted level of the player who died... For example I die and my wanted level was 5. Then wantedlevel = 5. Not the wanted level of the person that killed me.

I don't know what the hell is wrong... I though it was easy but I get lots of bugs with it
Reply
#8

Bump?
I still need help with this. Here is the code.
(my wanted level isn't detected)

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	//================[TAX]================//
	new string[128];
	new wantedlevel; wantedlevel = GetPlayerWantedLevel(playerid);
	new moneyamount; moneyamount = GetPlayerMoney(playerid);
	new tax;

	if(moneyamount < 0) { tax = (wantedlevel*((3/4)*-moneyamount))-random(1000); }
	if(moneyamount > 0) { tax = (wantedlevel*((3/4)*moneyamount))+random(1000); }
 	format(string, sizeof string, "Your total tax was %d$.", tax);
  	SendClientMessage(playerid, COLOR_ACHIEVEMENT, string);
  	GivePlayerMoney(playerid, -tax);
	return 1;
}
Reply
#9

Quote:
Originally Posted by jNkk
Посмотреть сообщение
Bump?
I still need help with this. Here is the code.
(my wanted level isn't detected)

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	//================[TAX]================//
	new string[128];
	new wantedlevel; wantedlevel = GetPlayerWantedLevel(playerid);
	new moneyamount; moneyamount = GetPlayerMoney(playerid);
	new tax;

	if(moneyamount < 0) { tax = (wantedlevel*((3/4)*-moneyamount))-random(1000); }
	if(moneyamount > 0) { tax = (wantedlevel*((3/4)*moneyamount))+random(1000); }
 	format(string, sizeof string, "Your total tax was %d$.", tax);
  	SendClientMessage(playerid, COLOR_ACHIEVEMENT, string);
  	GivePlayerMoney(playerid, -tax);
	return 1;
}
(wantedlevel*((3/4)*-moneyamount))-random(1000);
Try -> wantedlevel*floatround((-moneyamount*3)/4)-random(1000);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)