Help me with OnPlayerKeyStateChange[SOLVED]
#1

My codes:
Define:
Код:
#define PRESSED(%0) \
	(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
Code:
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_SUBMISSION))
    {
    new vehicleid = GetPlayerVehicleID(playerid);
    if(IsPlayerInVehicle(playerid, vehicleid))
    {
	  if(vehicleid == 560)
	  		{
	  		AddVehicleComponent(vehicleid, 1026);
	  		AddVehicleComponent(vehicleid, 1027);
	  		AddVehicleComponent(vehicleid, 1028);
	  		AddVehicleComponent(vehicleid, 1033);
	  		AddVehicleComponent(vehicleid, 1069);
	  		AddVehicleComponent(vehicleid, 1041);
	  		AddVehicleComponent(vehicleid, 1039);
    		}
	  }
}
return 1;
}
When i start the server , when i pressin the submission key, i see no effect
Reply
#2

The IsPlayerInVehicle check isn't necessary because the GetPlayerVehicleID function call is already clarifying that the player is in the vehicle. Although, that wouldn't cause the code to fail. I can't see any further problems. Try adding some debug statements, make sure your vehicle ID is definitely the correct one. (Not to get confused with vehicle IDs and vehicle Models).
Reply
#3

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_SUBMISSION)
{
 new vehicleid = GetPlayerVehicleID(playerid);
    if(IsPlayerInVehicle(playerid, vehicleid))
    {
	  if(vehicleid == 560)
	  		{
	  		AddVehicleComponent(vehicleid, 1026);
	  		AddVehicleComponent(vehicleid, 1027);
	  		AddVehicleComponent(vehicleid, 1028);
	  		AddVehicleComponent(vehicleid, 1033);
	  		AddVehicleComponent(vehicleid, 1069);
	  		AddVehicleComponent(vehicleid, 1041);
	  		AddVehicleComponent(vehicleid, 1039);
    		}
	  }
}
return 1;
}
try this one
Reply
#4

That method will not resolve the problem. It's much better, efficient and more accurate to use the PRESSED define. Additionally, I suggest you read my above post.
Reply
#5

thnx i will try!
Reply
#6

it's does not wont to work
Reply
#7

Quote:
Originally Posted by Nexotronix
it's does not wont to work
mine is not working ?
Reply
#8

try other key

old key:

pawn Код:
if(newkeys & KEY_SUBMISSION)
try to replace this:

pawn Код:
if(newkeys & KEY_JUMP)
or try

pawn Код:
if(newkeys == KEY_SUBMISSION)
Reply
#9

Quote:
Originally Posted by Brian_Furios
try other key

old key:

pawn Код:
if(newkeys & KEY_SUBMISSION)
try to replace this:

pawn Код:
if(newkeys & KEY_JUMP)
he needs submission key he doesnt ask for any other key
Reply
#10

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == KEY_SUBMISSION)
{
 new vehicleid = GetPlayerVehicleID(playerid);
    if(IsPlayerInVehicle(playerid, vehicleid))
    {
      if(vehicleid == 560)
            {
            AddVehicleComponent(vehicleid, 1026);
            AddVehicleComponent(vehicleid, 1027);
            AddVehicleComponent(vehicleid, 1028);
            AddVehicleComponent(vehicleid, 1033);
            AddVehicleComponent(vehicleid, 1069);
            AddVehicleComponent(vehicleid, 1041);
            AddVehicleComponent(vehicleid, 1039);
            }
      }
}
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)