//Under OnPlayerKeyStateChange
if(newkeys & KEY_CTRL_BACK) Enter_Hydra(playerid);
//Outside any other callback
stock Enter_Hydra(playerid)
{
new veh = GetHydraInRange(playerid);
if(!veh) return 0;
switch(IsHydraSeatFree(veh))
{
case true: PutPlayerInVehicle(playerid,veh,1);
}
return 1;
}
stock GetHydraInRange(playerid)
{
for(new i,l=GetVehiclePoolSize()+1,Float:p[3]; i<l; i++)
{
if(GetVehicleModel(i) != 520) continue;
GetVehiclePos(i,p[0],p[1],p[2]);
if(IsPlayerInRangeOfPoint(playerid,6.5,p[0],p[1],p[2])) return i;
}
return 0;
}
stock IsHydraSeatFree(veh)
{
for(new i,l=GetPlayerPoolSize()+1; i<l; i++)
{
if(GetPlayerVehicleID(i) != veh) continue;
if(GetPlayerVehicleSeat(i) == 1) return 0;
}
return 1;
}
You can't detect the key G.
But another key, for example H: PHP код:
|
C:\Users\Charalambos\Desktop\bible\gamemodes\WarZ.pwn(3567) : error 017: undefined symbol "GetVehiclePoolSize"
C:\Users\Charalambos\Desktop\bible\gamemodes\WarZ.pwn(3577) : error 017: undefined symbol "GetPlayerPoolSize"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
2 Errors.
stock GetHydraInRange(playerid)
{
for(new i,Float:p[3]; i<MAX_VEHICLES; i++)
{
if(GetVehicleModel(i) != 520) continue;
GetVehiclePos(i,p[0],p[1],p[2]);
if(IsPlayerInRangeOfPoint(playerid,6.5,p[0],p[1],p[2])) return i;
}
return 0;
}
stock IsHydraSeatFree(veh)
{
for(new i; i<MAX_PLAYERS; i++)
{
if(GetPlayerVehicleID(i) != veh) continue;
if(GetPlayerVehicleSeat(i) == 1) return 0;
}
return 1;
}
Oh u don't use 0.3.7?
You can Update your Includes for this version...or change it to this: PHP код:
|
C:\Users\Charalambos\Desktop\bible\gamemodes\WarZ.pwn(4531) : error 017: undefined symbol "Enter_Hydra"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
1 Error.
new GetVehicleID[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
GetVehicleID[playerid] = 0;
return 1;
}
public OnPlayerSpawn(playerid)
{
new vehicleid = GetVehicleID[playerid];
GetVehicleID[playerid] = 0;
if(vehicleid)
{
new Float:X, Float:Y, Float:Z, Float:A;
GetVehiclePos(vehicleid,X,Y,Z);
GetVehicleZAngle(vehicleid,A);
SetPlayerPos(playerid,X-4.0,Y+2.0,Z+0.5);
SetPlayerFacingAngle(playerid,A);
return 1;
}
// rest your code from GM
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(ispassenger)
{
if(!GetVehicleID[playerid] && GetVehicleModel(vehicleid) == 520)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
if(GetVehicleDistanceFromPoint(vehicleid, X, Y, Z) < 5.6)
{
GetVehicleID[playerid] = vehicleid;
TogglePlayerSpectating(playerid, 1);
PlayerSpectateVehicle(playerid, vehicleid);
return 0;
}
}
}
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if((newkeys & KEY_SECONDARY_ATTACK) && 0 < GetVehicleID[playerid] < MAX_VEHICLES)
{
if(GetVehicleModel(GetVehicleID[playerid])) // if hydra exist (you can use IsValidVehicle instead of GetVehicleModel if you got this native in inc
TogglePlayerSpectating(playerid, 0);
else
{
GetVehicleID[playerid] = 0;
if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING)
TogglePlayerSpectating(playerid, 0);
}
return 0;
}
return 1;
}