Help with SetVehicleVelocity with OnPlayerKeyStateChange.
#1

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.
Reply
#2

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;
}
Reply
#3

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

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.
Reply
#5

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.
Reply
#6

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.
Reply
#7

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 )))))))))))))
Reply
#8

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

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

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


Forum Jump:


Users browsing this thread: 2 Guest(s)