SA-MP Forums Archive
Help with SetVehicleVelocity with OnPlayerKeyStateChange. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with SetVehicleVelocity with OnPlayerKeyStateChange. (/showthread.php?tid=111611)



Help with SetVehicleVelocity with OnPlayerKeyStateChange. - speedruntrainer - 02.12.2009

Hello, I have a problem with SetPlayerVelocity with OnPlayerKeyStateChange.
I can't find the solution, here is the code, (I made a new script for testing it)

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (PRESSED(KEY_FIRE))
{
new
vehicleid = GetPlayerVehicleID(playerid);
if (vehicleid)
{
SetVehicleVelocity(playerid, 0.0, 0,5, 0.0);
}
}
return 1;
}
return 0;
}
Код:
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Sa-mp 0.3\sa-mp 0.3a\filterscripts\cmdtests.pwn(14) : error 029: invalid expression, assumed zero
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Sa-mp 0.3\sa-mp 0.3a\filterscripts\cmdtests.pwn(14) : error 004: function "OnPlayerKeyStateChange" is not implemented
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Sa-mp 0.3\sa-mp 0.3a\filterscripts\cmdtests.pwn(16) : warning 206: redundant test: constant expression is non-zero
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Sa-mp 0.3\sa-mp 0.3a\filterscripts\cmdtests.pwn(22) : warning 202: number of arguments does not match definition
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Sa-mp 0.3\sa-mp 0.3a\filterscripts\cmdtests.pwn(27) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Can someone help me? I got the OnPlayerKeyStateChange function on the wiki.

EDIT: Newer code:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
  if (PRESSED(KEY_FIRE))
  {
    if(IsPlayerInAnyVehicle(playerid)) SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 0,5, 0.0);
  }
  return 1;
}
Код:
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Sa-mp 0.3\sa-mp 0.3a\filterscripts\cmdtests.pwn(14) : error 029: invalid expression, assumed zero
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Sa-mp 0.3\sa-mp 0.3a\filterscripts\cmdtests.pwn(14) : error 004: function "OnPlayerKeyStateChange" is not implemented
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Sa-mp 0.3\sa-mp 0.3a\filterscripts\cmdtests.pwn(16) : warning 206: redundant test: constant expression is non-zero
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Sa-mp 0.3\sa-mp 0.3a\filterscripts\cmdtests.pwn(18) : warning 202: number of arguments does not match definition
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Sa-mp 0.3\sa-mp 0.3a\filterscripts\cmdtests.pwn(22) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.



Re: Help with SetVehicleVelocity with OnPlayerKeyStateChange. - Ace_Menace - 02.12.2009

You're missing one of the core includes.

Try to add these:

pawn Код:
#include <a_samp>
#include <core>
#include <float>
#include <time>
#include <file>
#include <utils>
#include <morphinc>

Also Sounds like you are messing up your indentations.

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
   if (PRESSED(KEY_FIRE))
   {
     new vehicleid = GetPlayerVehicleID(playerid);
     if (vehicleid)
     {
       SetVehicleVelocity(playerid, 0.0, 0,5, 0.0);
     }
   }
   return 1;
}
return 0;
}



Re: Help with SetVehicleVelocity with OnPlayerKeyStateChange. - Sergei - 02.12.2009

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
  if (PRESSED(KEY_FIRE))
  {
    if(IsPlayerInAnyVehicle(playerid)) SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 0,5, 0.0);
  }
  return 1;
}



Re: Help with SetVehicleVelocity with OnPlayerKeyStateChange. - radhakr - 02.12.2009

Quote:
Originally Posted by Ace_Menace
You're missing one of the core includes.

Try to add these:

pawn Код:
#include <a_samp>
#include <core>
#include <float>
#include <time>
#include <file>
#include <utils>
#include <morphinc>
If you open up a_samp.inc and you will see this:

pawn Код:
#include <core>
#include <float>
#include <string>
#include <file>
#include <time>
#include <datagram>
#include <a_players>
#include <a_vehicles>
#include <a_objects>
#include <a_sampdb>
So all you need to add is #include <a_samp> to include the first 5. The last 2 are not supplied with the server package and so unless someone happens to have downloaded them, they cannot use them. Finally, morphinc is outdated and SetNameTagDrawDistance can be used instead of it.


Re: Help with SetVehicleVelocity with OnPlayerKeyStateChange. - lolumadd - 02.12.2009

Quote:
Originally Posted by Ace_Menace
You're missing one of the core includes.
Dude what the fuck are you talking about?
Dont tell what you don't know.


Re: Help with SetVehicleVelocity with OnPlayerKeyStateChange. - Grim_ - 02.12.2009

Quote:
Originally Posted by lolumadd [cod5server.tk
]
Quote:
Originally Posted by Ace_Menace
You're missing one of the core includes.
Dude what the fuck are you talking about?
Dont tell what you don't know.
Comeon, was that really needed?
Anyways, make sure you have #include <a_samp> at the top of your script.


Re: Help with SetVehicleVelocity with OnPlayerKeyStateChange. - speedruntrainer - 02.12.2009

pfff, even with those f...... includes I get the same errors, I bet I don't need to use them.
But ofcourse I have included #include <a_samp> and #include <a_players>
Btw the code is even better now with these errors but still errors :/

The whole new script looks like thisЎЎ

pawn Код:
#include <a_samp>
#include <a_players>

#define PRESSED

public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/jump", true) == 0) {
if(IsPlayerInAnyVehicle(playerid)) SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0,0.0,1.0);
else SetPlayerVelocity(playerid,0.0,0.0,1.0);
return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
  if (PRESSED(KEY_FIRE))
  {
    if(IsPlayerInAnyVehicle(playerid)) SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 0,5, 0.0);
  }
  return 1;
}
return 0;
}
The ugly errors and warnings looks like this:
Код:
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Sa-mp 0.3\sa-mp 0.3a\filterscripts\cmdtests.pwn(14) : error 029: invalid expression, assumed zero
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Sa-mp 0.3\sa-mp 0.3a\filterscripts\cmdtests.pwn(14) : error 004: function "OnPlayerKeyStateChange" is not implemented
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Sa-mp 0.3\sa-mp 0.3a\filterscripts\cmdtests.pwn(16) : warning 206: redundant test: constant expression is non-zero
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Sa-mp 0.3\sa-mp 0.3a\filterscripts\cmdtests.pwn(18) : warning 202: number of arguments does not match definition
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Sa-mp 0.3\sa-mp 0.3a\filterscripts\cmdtests.pwn(22) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Can anyone help me, I want to use it so much )))))))))))))


Re: Help with SetVehicleVelocity with OnPlayerKeyStateChange. - Grim_ - 02.12.2009

IDK, but you're missing a bracket "}" after this line:
pawn Код:
if(IsPlayerInAnyVehicle(playerid)) SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0,0.0,1.0);



Re: Help with SetVehicleVelocity with OnPlayerKeyStateChange. - Joe Staff - 03.12.2009

pawn Код:
#define PRESSED
I'm pretty sure there's more to that, look here.


Re: Help with SetVehicleVelocity with OnPlayerKeyStateChange. - Grim_ - 03.12.2009

You also have an extra bracket before the 'return 1;' in the OnPlayerKeyStateChange callback.