Why and How?
#1

Why when i press TAB it's saying "You have to be in a car!" ?
I maded it so i when you press 2 to fix your car. but when i press TAB it says "You have to be in a car" Of course in car when i press TAB it doesn't happen anything, only when i press 2 everything works, the only problem is why when i press TAB it's saying "You have to be in a car!".


Can someone tell me how to fix it, and why is happening this?

Here's the code:

Код:
#define PRESSED(%0) \
	(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#define IsPlayerNotInVehicle(%0) (!IsPlayerInAnyVehicle(%0))


public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
       if(PRESSED(KEY_SUBMISSION))
       {
           new vehicleid = GetPlayerVehicleID(playerid);
           if(IsPlayerInVehicle(playerid, vehicleid))
           {
       		  SetVehicleHealth(vehicleid,1000.0);
              RepairVehicle(GetPlayerVehicleID(playerid));
			  PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
       		  SendClientMessage(playerid,-1,"Car fixed!");
	       }
       }
       if(PRESSED(KEY_ACTION))
       {
         if(IsPlayerNotInVehicle(playerid))
         {
  		     SendClientMessage(playerid,-1,"You have to be in a car!");
	     }
       }
	   return 1;
}
Reply
#2

you only placed the repair vehicle code on when player press '2' and when player press tab, you set the code to show the msg only.

you can try this
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
       if(PRESSED(KEY_SUBMISSION))
       {
           new vehicleid = GetPlayerVehicleID(playerid);
           if(IsPlayerInVehicle(playerid, vehicleid))
           {
       		  SetVehicleHealth(vehicleid,1000.0);
              RepairVehicle(GetPlayerVehicleID(playerid));
			  PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
       		  SendClientMessage(playerid,-1,"Car fixed!");
	       }
       }
       if(PRESSED(KEY_ACTION))
       {
         new vehicleid = GetPlayerVehicleID(playerid);
           if(IsPlayerInVehicle(playerid, vehicleid))
           {
       		  SetVehicleHealth(vehicleid,1000.0);
              RepairVehicle(GetPlayerVehicleID(playerid));
			  PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
       		  SendClientMessage(playerid,-1,"Car fixed!");
	       }
       }
}
Reply
#3

TAB is assigned to the KEY_ACTION key internally in San Andreas. (Differs for different keybinds obviously) - your code has no actual functionality assigned to KEY_ACTION, its only purpose there is to moan at you.

https://sampwiki.blast.hk/wiki/Keys
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)