[PROBLEM] Tram not accessible - 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: [PROBLEM] Tram not accessible (
/showthread.php?tid=639314)
[PROBLEM] Tram not accessible -
spyro9696 - 15.08.2017
In this way, I can get into all rc vehicles except the tram...
Why
PHP код:
#include <a_samp>
#include <sscanf2>
#include <zcmd>
#include <cuffs>
#define RC_ENTER_RANGE 8
new RCVehicles[] = {
441,
464,
465,
501,
564,
594,
449
};
main()
{
print("\n----------------------------------");
print(" By Crystal94");
print("----------------------------------\n");
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & 16)
{
new Float:x,Float:y,Float:z;
if(IsPlayerInAnyVehicle(playerid) && IsVehicleRCVehicle(GetPlayerVehicleID(playerid)))
{
GetVehiclePos(GetPlayerVehicleID(playerid),x,y,z);
SetPlayerPos(playerid,x,y,z+1.8);
return 1;
}
for(new v; v < MAX_VEHICLES; v++)
{
GetVehiclePos(v,x,y,z);
if(IsPlayerInRangeOfPoint(playerid,RC_ENTER_RANGE,x,y,z) && IsVehicleRCVehicle(v))
{
PutPlayerInVehicle(playerid,v,0);
return 1;
}
}
}
return 1;
}
stock IsVehicleRCVehicle(vehicleid)
{
for(new v; v < 6; v++)
{
if(GetVehicleModel(vehicleid) == RCVehicles[v]) return 1;
}
return 0;
}
Re: [PROBLEM] Tram not accessible -
Vince - 15.08.2017
That's what you get when people refuse to use sizeof. Specifically this:
PHP код:
for(new v; v < 6; v++)
It checks the first 6 items in the array but now there are 7 items so the last item isn't checked at all. If it had been done properly it would look like this:
PHP код:
for(new v; v < sizeof RCVehicles; v++)
Re: [PROBLEM] Tram not accessible -
spyro9696 - 15.08.2017
Okay, come in, but when I want to get out there is a problem, because if I press enter, Cj comes out, but for a fraction of a second and then returns inside.
Holding Enter together the directional keys, somehow I can go out, but the camera stays on the tram, like in this image: