22.03.2011, 05:59
Hello i'm using this!
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!
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;
}