Vehicle Hopping
#1

So, i have this code:
pawn Код:
if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  {
  if (newkeys & KEY_CROUCH)
  {
  new Float:xx, Float:xy, Float:xz;
  GetVehicleVelocity(GetPlayerVehicleID(playerid), xx, xy, xz);
  SetVehicleVelocity(GetPlayerVehicleID(playerid), xx, xy, xz + sf);
  return 1;
  }
  }
How can i make a command what disabled/enables it ?
Reply
#2

Sorry for double post, but i need help !
Reply
#3

OMG, just use variable!
Reply
#4

How ?
Reply
#5

You can make a variable between the functions

For example here only admins can do this..

Код:
  
if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  {
  if(isplayeradmin(playerid)
  {
  if (newkeys & KEY_CROUCH)
  {
  new Float:xx, Float:xy, Float:xz;
  GetVehicleVelocity(GetPlayerVehicleID(playerid), xx, xy, xz);
  SetVehicleVelocity(GetPlayerVehicleID(playerid), xx, xy, xz + sf);
  }
  }
  return 1; 
  }
I suggest you try out the new setvparint function here to make your own 'variable'
https://sampwiki.blast.hk/wiki/SetPVarInt

Reply
#6

pawn Код:
if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  {
  if (newkeys & KEY_CROUCH)
  {
   if( GetPVarInt( playerid, "Hop" ) >= 1 )
   {
     new Float:xx, Float:xy, Float:xz;
     GetVehicleVelocity(GetPlayerVehicleID(playerid), xx, xy, xz);
     SetVehicleVelocity(GetPlayerVehicleID(playerid), xx, xy, xz + sf);
     return 1;
   }
  }
  }
Then create a command:

pawn Код:
if( GetPVarInt( playerid, "Hop" ) >= 1 )
{
SetPVarInt( playerid, "Hop", 0 );
}
else
{
SetPVarInt( playerid, "Hop", 1 );
}
Reply
#7

How i do this command ?

Like this ?
pawn Код:
if (strcmp("/jump", cmdtext, true) == 0)
  {
  if( GetPVarInt( playerid, "Hop" ) >= 1 )
  {
  SetPVarInt( playerid, "Hop", 0 );
  }
  else
  {
  SetPVarInt( playerid, "Hop", 1 );
  }
  return 1;
  }
Reply
#8

When you added the stuff the other guy posted make a command like this;

Код:
if (strcmp("/jump", cmdtext, true) == 0)
  {
  if( GetPVarInt( playerid, "Hop" ) >= 1 )
{
  if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  {
  if (newkeys & KEY_CROUCH)
  {
  new Float:xx, Float:xy, Float:xz;
  GetVehicleVelocity(GetPlayerVehicleID(playerid), xx, xy, xz);
  SetVehicleVelocity(GetPlayerVehicleID(playerid), xx, xy, xz + sf);
}
}
}
  return 1;
  
  }
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)