Hydra G Passanger Entering
#1

Hello,
does anybody have the Script for entering a Hydra as a Passanger with G?
Thx
Reply
#2

You can't detect the key G.

But another key, for example H:

PHP код:
//Under OnPlayerKeyStateChange
if(newkeys KEY_CTRL_BACKEnter_Hydra(playerid);
//Outside any other callback
stock Enter_Hydra(playerid)
{
    new 
veh GetHydraInRange(playerid);
    if(!
veh) return 0;
    switch(
IsHydraSeatFree(veh))
    {
        case 
truePutPlayerInVehicle(playerid,veh,1);
    }
    return 
1;
}
stock GetHydraInRange(playerid)
{
    for(new 
i,l=GetVehiclePoolSize()+1,Float:p[3]; i<li++)
    {
        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()+1i<li++)
    {
        if(
GetPlayerVehicleID(i) != veh) continue;
        if(
GetPlayerVehicleSeat(i) == 1) return 0;
    }
    return 
1;

Greekz
Reply
#3

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
You can't detect the key G.

But another key, for example H:

PHP код:
//Under OnPlayerKeyStateChange
if(newkeys KEY_CTRL_BACKEnter_Hydra(playerid);
//Outside any other callback
stock Enter_Hydra(playerid)
{
    new 
veh GetHydraInRange(playerid);
    if(!
veh) return 0;
    switch(
IsHydraSeatFree(veh))
    {
        case 
truePutPlayerInVehicle(playerid,veh,1);
    }
    return 
1;
}
stock GetHydraInRange(playerid)
{
    for(new 
i,l=GetVehiclePoolSize()+1,Float:p[3]; i<li++)
    {
        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()+1i<li++)
    {
        if(
GetPlayerVehicleID(i) != veh) continue;
        if(
GetPlayerVehicleSeat(i) == 1) return 0;
    }
    return 
1;

Greekz
Hey bro,
got errors :/

PHP код:
C:\Users\Charalambos\Desktop\bible\gamemodes\WarZ.pwn(3567) : error 017undefined symbol "GetVehiclePoolSize"
C:\Users\Charalambos\Desktop\bible\gamemodes\WarZ.pwn(3577) : error 017undefined symbol "GetPlayerPoolSize"
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
2 Errors

Reply
#4

Oh u don't use 0.3.7?

You can Update your Includes for this version...or change it to this:

PHP код:
stock GetHydraInRange(playerid

    for(new 
i,Float:p[3]; i<MAX_VEHICLESi++) 
    { 
        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 
ii<MAX_PLAYERSi++) 
    { 
        if(
GetPlayerVehicleID(i) != veh) continue; 
        if(
GetPlayerVehicleSeat(i) == 1) return 0
    } 
    return 
1

Greekz
Reply
#5

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
Oh u don't use 0.3.7?

You can Update your Includes for this version...or change it to this:

PHP код:
stock GetHydraInRange(playerid

    for(new 
i,Float:p[3]; i<MAX_VEHICLESi++) 
    { 
        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 
ii<MAX_PLAYERSi++) 
    { 
        if(
GetPlayerVehicleID(i) != veh) continue; 
        if(
GetPlayerVehicleSeat(i) == 1) return 0
    } 
    return 
1

Greekz
im using 0.3.7

But adding your code still gives me 1 error

PHP код:
C:\Users\Charalambos\Desktop\bible\gamemodes\WarZ.pwn(4531) : error 017undefined symbol "Enter_Hydra"
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
1 Error

Reply
#6

Quote:
Originally Posted by FrankLucretti
Посмотреть сообщение
im using 0.3.7
Then check that you start the right pawno
Reply
#7

Im not sure why nothing happens (didn't bother to read), because the Hydra (model: 520) does not have any valid "extra" seats.
You can force the player to enter the Hydra; (like above)
however, reading the Wiki:



So, when a player eventually exits the vehicle, the client will crash- This is not suggested.

I don't know about any workarounds, or if this has been scripted to work somewhere else.
Reply
#8

Paste this into GM otherwise it will not work

pawn Код:
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;
}
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)