Problem with my code
#1

Ok I've been trying all day trying to make this work..

But i'm out of ideas, Maybe you can help?


Well i've made a nitro button, And a invaild vehicle command, asswell.

Here it is.


Quote:
if(IsPlayerInAnyVehicle(playerid))
{

if(newkeys & KEY_FIRE)
{

if(IsPlayerInAnyVehicle(playerid))
AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);


}
else
if(GetPlayerVehicleID(playerid) != 522)
{
RemoveVehicleComponent(522,1010);
}

return 1;

So maybe you know why the code doesn't stop the vehicle from installing nitro..

If you know please reply with a good answer.

thanks

Xtreme.
Reply
#2

Код:
if(IsPlayerInAnyVehicle(playerid))
{

if(newkeys & KEY_FIRE && GetPlayerVehicleID(playerid) != 522)
{
  AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
  
}
else if(newkeys & KEY_FIRE && GetPlayerVehicleID(playerid) == 522)
{
  RemoveVehicleComponent(522,1010);
}
}
Not tested / compiled
Reply
#3

Quote:
Originally Posted by Faith
Код:
if(IsPlayerInAnyVehicle(playerid))
{

if(newkeys & KEY_FIRE && GetPlayerVehicleID(playerid) != 522)
{
  AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
  
}
else
{
  RemoveVehicleComponent(522,1010);
}
}
Thank you are test it in a miniute

But first can you tell me what i did wrong?
Reply
#4

Well heres my code..


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

if(IsPlayerInAnyVehicle(playerid))
{

if(newkeys & KEY_FIRE && GetPlayerVehicleID(playerid) != 522)
{
  AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);

}
else if(newkeys & KEY_FIRE && GetPlayerVehicleID(playerid) == 522)
{
  RemoveVehicleComponent(522,1010);
}
}
return 1;
}

{
Geting some errors tho know why?

Xtreme.
Reply
#5

what are the errors
Reply
#6

Quote:
Originally Posted by Kar
what are the errors
Код:
C:\Users\(lewis)\Desktop\New Folder (11)\Stunts.pwn(1260) : error 055: start of function body without function header
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#7

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

if(IsPlayerInAnyVehicle(playerid))
{

if(newkeys & KEY_FIRE && GetPlayerVehicleID(playerid) != 522)
{
  AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);

}
else if(newkeys & KEY_FIRE && GetPlayerVehicleID(playerid) == 522)
{
  RemoveVehicleComponent(522,1010);
}
}
return 1;
}
why was there an exact starting bracket in there lol
Reply
#8

Quote:
Originally Posted by Kar
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{

if(IsPlayerInAnyVehicle(playerid))
{

if(newkeys & KEY_FIRE && GetPlayerVehicleID(playerid) != 522)
{
  AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);

}
else if(newkeys & KEY_FIRE && GetPlayerVehicleID(playerid) == 522)
{
  RemoveVehicleComponent(522,1010);
}
}
return 1;
}
why was there an exact starting bracket in there lol
Lol idk.

My Bad,

Thanks Kar..

Off topic: You got Gangsta postion nice!
Reply
#9

Omg.

I still crash -.-

with this code anymore ideas?
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{

if(IsPlayerInAnyVehicle(playerid))
{

if(newkeys & KEY_FIRE && GetPlayerVehicleID(playerid) != 522)
{
  AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);

}
else if(newkeys & KEY_FIRE && GetPlayerVehicleID(playerid) == 522)
{
  RemoveVehicleComponent(522,1010);
}
}
return 1;
}
Reply
#10

line and error :\

or its crashing your compiler>?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)