GetVehicleHealth error and other errors. -
Martin_White - 09.08.2009
Compile:
Код:
C:\Documents and Settings\Administrator\Desktop\samp02Xserver.win32\filterscripts\nearexplow.pwn(8) : error 017: undefined symbol "vehicleid"
C:\Documents and Settings\Administrator\Desktop\samp02Xserver.win32\filterscripts\nearexplow.pwn(14) : error 076: syntax error in the expression, or invalid function call
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
Script:
pawn Код:
#include <a_samp>
new nearexplow[MAX_PLAYERS];
forward OnPlayerUpdate(playerid);
new Float:vHealth;
public OnPlayerUpdate(playerid)
{
GetVehicleHealth(vehicleid, vHealth);
if (vHealth < 300.0)
{
TogglePlayerControllable(playerid, 0);
nearexplow[playerid]=true;
}
if (TogglePlayerControllable == 1)
{
nearexplow[playerid]=false;
}
return 1;
}
First off, i do not want to define a TARGETED vehicle id, i want everyone who is in a vehicle that its health reached 300, then it TogglePlayerControllable to 0
And when he gets out of the car, the nearexplow goes to false..
Re: GetVehicleHealth error and other errors. -
Weirdosport - 09.08.2009
Well the first error is because the vehicleid is undefined. Simply putting vehicleid there doesn't give it a value, so you need to make the script determine the value.
For this you first need to check if the player is in a vehicle, and if they are you need to use GetPlayerVehicleID(playerid).
The second error, is because this is tosh: if (TogglePlayerControllable == 1)
TogglePlayerControllable is a function, not a variable, and it doesn't return a value anywho...
To the best of my knowledge there is no function to check whether the player is "frozen" or not, but as I don't know what you're trying to achieve here I don't know how to best advise you.
EDIT: Also, if you have the latest pawno etc etc, you shouldn't need this: forward OnPlayerUpdate(playerid);
Re: GetVehicleHealth error and other errors. -
Martin_White - 09.08.2009
Okay, osport,
What i am trying to achieve is:
When the player is in a car, and the car health reaches 300, it should freeze the player, and to disable OnPlayerUpdate to keep freezing him ( so when he gets out unfrozen, he will not be frozen again ) so i have to set the variable ( nearexplow ) to false, and to do that, i need to find a variable to set it to false
I will make a new variable with a timer, i think it is the only solution.
Re: GetVehicleHealth error and other errors. -
WrathOfGenesis - 09.08.2009
pawn Код:
#include <a_samp>
new nearexplow [ MAX_PLAYERS ];
forward OnPlayerUpdate ( );
new Float:vHealth;
public OnPlayerUpdate ( )
{
for ( new vehicleid = 0; vehicleid < MAX_VEHICLES; vehicleid ++ )
{
GetVehicleHealth ( vehicleid , vHealth );
if ( vHealth < 300.0 )
{
for ( new playerid = 0; playerid < MAX_PLAYERS; playerid ++ )
{
if ( IsPlayerConnected ( playerid ) && GetPlayerVehicleID ( playerid ) == vehicleid )
{
TogglePlayerControllable ( playerid , 0 );
nearexplow [ playerid ] = true;
}
}
}
}
return 1;
}
public OnPlayerExitVehicle ( playerid , vehicleid )
{
nearexplow [ playerid ] = false;
return 1;
}
Untested but should work if what you want is what i think you want
Re: GetVehicleHealth error and other errors. -
Martin_White - 09.08.2009
Will test.
Edit::
It freezes me directly when i spawn
Re: GetVehicleHealth error and other errors. -
Martin_White - 09.08.2009
It is freezing me directly when spawning.
Re: GetVehicleHealth error and other errors. -
WrathOfGenesis - 09.08.2009
pawn Код:
#include <a_samp>
new nearexplow [ MAX_PLAYERS ];
forward OnPlayerUpdate ( );
new Float:vHealth;
public OnPlayerUpdate ( )
{
for ( new vehicleid = 1; vehicleid < MAX_VEHICLES; vehicleid ++ )
{
GetVehicleHealth ( vehicleid , vHealth );
if ( vHealth < 300.0 )
{
for ( new playerid = 0; playerid < MAX_PLAYERS; playerid ++ )
{
if ( IsPlayerConnected ( playerid ) && GetPlayerVehicleID ( playerid ) == vehicleid )
{
TogglePlayerControllable ( playerid , 0 );
nearexplow [ playerid ] = true;
}
}
}
}
return 1;
}
public OnPlayerExitVehicle ( playerid , vehicleid )
{
nearexplow [ playerid ] = false;
return 1;
}
My mistake. Try it now.
Re: GetVehicleHealth error and other errors. -
Martin_White - 09.08.2009
Still freezes me mate.
Re: GetVehicleHealth error and other errors. -
Weirdosport - 09.08.2009
Still not 100% sure what you want, but I'm going to have a go at it.. and WoG, why the need for loops, as the callback OnPlayerUpdate has the "attribute" playerid in it.
pawn Код:
#include <a_samp>
new
NearExplode[MAX_PLAYERS],
Float:vHealth;
public OnPlayerUpdate(playerid)
{
if(IsPlayerInAnyVehicle(playerid))
{
GetVehicleHealth(GetPlayerVehicleID(playerid), vHealth);
if(vHealth < 300.0)
{
TogglePlayerControllable(playerid, 0);
NearExplode[playerid] = 1;
}
}
else if(NearExplode[playerid] == 1)
{
TogglePlayerControllable(playerid, 1);
}
return 1;
}
Player in a vehicle with less than 300.0 health are frozen. If a player is not in a vehicle, and their NearExplode = 1, they're unfrozen.
Re: GetVehicleHealth error and other errors. -
WrathOfGenesis - 09.08.2009
Oops, sorry about that. Forgot OnPlayerUpdate is a real function because ive never used it myself. I thought it was a timer :P
Btw, i wouldnt put too much in there. I think you should be able to use it like that but if you put too much more in there, it might cause problems.