SA-MP Forums Archive
[HELP]Enterable Tram bug? - 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)
+--- Thread: [HELP]Enterable Tram bug? (/showthread.php?tid=243234)



[HELP]Enterable Tram bug? - Nexotronix - 22.03.2011

Hello i'm using this!

pawn Код:
#include <a_samp>

#define RC_BANDIT   441
#define RC_BARON    464
#define RC_GOBLIN   501
#define RC_RAIDER   465
#define D_TRAM      449
#define RC_TANK     564
#define RC_CAM      594


public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
    if(newkeys == KEY_SECONDARY_ATTACK) {
        new Float:x, Float:y, Float:z, vehicle;
        new vehicleID = GetPlayerVehicleID(playerid);
        if(vehicleID == 0) {
            GetPlayerPos(playerid, x, y, z);
            GetVehicleWithinDistance(x, y, z, 10.0, vehicle);
            if(IsVehicleRcTram(vehicle)) PutPlayerInVehicle(playerid, vehicle, 0);
        } else if(GetVehicleModel(vehicleID) != D_TRAM && (IsVehicleRcTram(vehicleID) || GetVehicleModel(vehicleID) == RC_CAM)) {
                        RemovePlayerFromVehicle(playerid); //NOT HELPFULL
            GetPlayerPos(playerid, x, y, z);
            SetPlayerPos(playerid, x+0.5, y, z+1.0);
                        SetCameraBehindPlayer(playerid); //NOT HELPFULL
        }
    }
}


GetVehicleWithinDistance(Float:x1, Float:y1, Float:z1, Float:dist, &veh) {
    new Float:x2, Float:y2, Float:z2, Float:d;
    for(new i = 1; i < MAX_VEHICLES; i++) {
        if(GetVehicleModel(i) > 0) {
            GetVehiclePos(i, x2, y2, z2);
            x2 -= x1; y2 -= y1; z2 -= z1;
            d = x2*x2 + y2*y2 + z2*z2;
            if(d < dist) {
                veh = i;
                dist = d;
            }
        }
    }
}

IsVehicleRcTram(vehicleid) {
    switch(GetVehicleModel(vehicleid)) {
        case D_TRAM, RC_GOBLIN, RC_BARON, RC_BANDIT, RC_RAIDER, RC_TANK: return 1;
    }
    return 0;
}
And when i entering to tram all going good, but when i exiting from it, camera sets on tram, but my state is on foot... so what is it, bug? or something wrong in code, please help!


Re: [HELP]Enterable Tram bug? - ancezas - 02.02.2012

can someone help with this bug?


Re: [HELP]Enterable Tram bug? - niels44 - 02.02.2012

maybe you can use this:
pawn Код:
SetCameraBehindPlayer(playerid);
i hope i helped you

EDIT: ow sorry i just saw what you had in your code XD sorry this wont help im afraid then...


Re: [HELP]Enterable Tram bug? - milanosie - 02.02.2012

Add SetCameraBehindPlayer(playerid);

at OnPlayerExitVehicle