SA-MP Forums Archive
Nos Key Problem - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Nos Key Problem (/showthread.php?tid=69378)



Nos Key Problem - FedorMS - 17.03.2009

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(newkeys & KEY_SUBMISSION) // if somebody presses 2
	{
		if(IsNosTimer[playerid] == true)
		{
			SendClientMessage(playerid, 0xFFFF00AA, "Please Wait Before Using NOS!");
			return 1;
		}

		if(IsMotorBike(GetVehicleModel(GetPlayerVehicleID(playerid))))
		{
			Nos = SetTimerEx("NosTimer", 15000, false, "i", playerid);
			IsNosTimer[playerid] = true;
			SendClientMessage(playerid, 0xFFFF00AA, "Vehicle Is Not Modifiable!");
			return 1;
		}

		if(!IsMotorBike(GetVehicleModel(GetPlayerVehicleID(playerid))))
		{
			Nos = SetTimerEx("NosTimer", 15000, false, "i", playerid);
    	IsNosTimer[playerid] = true;
			SetVehicleHealth(GetPlayerVehicleID(playerid), 1000); //set car health to 1000
			AddVehicleComponent(GetPlayerVehicleID(playerid), 1010); //give player 10x nos.
			PlayerPlaySound(playerid, 1133, 0, 0 ,0); // little sound
			return 1;
		}
		return 1;
	}
	return 1;
}
This code is fully functional until it reaches a bike. The result is a crash via clientside, so nobody can access it. I don't know what I'm doing wrong, I just can't make it cancel out when it's on a bike, it goes on anyways. :/

Appreciate any help given, thanks.

I haven't scripted in quite a while, so don't blame me. :P


Re: Nos Key Problem - MenaceX^ - 17.03.2009

Check if the player is inside a vehicle.


Re: Nos Key Problem - Weirdosport - 17.03.2009

It would probably be better if you used the "IsInvalidNosVehicle", as there are some non-motorbikes that crash when you add nos to them.


Re: Nos Key Problem - FedorMS - 19.03.2009

Quote:
Originally Posted by Weirdosport
It would probably be better if you used the "IsInvalidNosVehicle", as there are some non-motorbikes that crash when you add nos to them.
I'll get to that later, but I don't understand why it STILL applies NOS to a bike.


Re: Nos Key Problem - [HiC]TheKiller - 19.03.2009

Because sa-mp doesn't have a inbuild function to stop it so it F*CKS up. So how about you just do IsInvalidNosVehicle. Also GTA:SA Didn't need the function no nos add onto bikes because there was no way to.


Re: Nos Key Problem - FedorMS - 19.03.2009

Quote:
Originally Posted by [HiC
TheKiller ]
Because sa-mp doesn't have a inbuild function to stop it so it F*CKS up. So how about you just do IsInvalidNosVehicle. Also GTA:SA Didn't need the function no nos add onto bikes because there was no way to.
You mean sa-mp can't cancel out the callback? I should be able to break; / return 1; it and stop it successfully.

Edit: I can't find IsInvalidNosVehicle in the searchbar, can I get that code?