Help with my nitro button/command
#1

I've made a command with OnPlayerKeyStateChange.

Off nitro.

But theres a big problem, When the player presses the button on a bike they crash.


Is there away to block some vehicle ids?


Heres my code



Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(IsPlayerInAnyVehicle(playerid))
{

if(newkeys & KEY_FIRE)
{
	
	if(IsPlayerInAnyVehicle(playerid))
	AddVehicleComponent(GetPlayerVehicleID(playerid), 1010); 
}
return 1;
}
}
Reply
#2

Sorry for the bump, But this must be simple.
Reply
#3

Use an ARRAY.

pawn Код:
new BadVehicles[] =
{
400, 401, 402 // Place the ## MODEL ## Id's like I did here.
};

//Under your nos command

for(new a = 0; a < sizeof(BadVehicles); a++)
{
new model = GetVehicleModel(vehicleid);
if(model != BadVehicles[a])
{
//Do your nitro
}
SendClientMessage(playerid, COLOR, "Gtfo cr44shing my s3rv00r n33b!!111!11");
}
Reply
#4

Check if the vehicle model isn't a bike model.

if(GetVehicleModelID(GetPlayerVehicleID(playerid) != bike id)

Didn't YSI had a IsPlayerInBike function?
Reply
#5

Thanks guyz.
Reply
#6

I prefer Arrays/varibles to Functions, and using

if(model == bike || model == ..)

Is just crap and extremely static, it would be annoying editing it, so an array is much more convinient.
Reply
#7

Quote:
Originally Posted by Joe_
I prefer Arrays/varibles to Functions, and using

if(model == bike || model == ..)

Is just crap and extremely static, it would be annoying editing it, so an array is much more convinient.
I used your code btw joe.


Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)