PDA

View Full Version : Exit position garage bug.


Songason
30/10/2013, 09:13 PM
When I /exitgarage, I come in the middle of nowhere. This happens in every garage.

Code of /entergarage + /exitgarage:
if(strcmp(cmd, "/entergarage", true) == 0 || strcmp(cmd, "/enterga", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new Seat[MAX_PLAYERS], InCar[MAX_PLAYERS];
new i = IsPlayerNearGarage(playerid), intoset, vehicleid;
if(i == -1) return SendClientMessage(playerid, GREY, " You are not near a garage.");
if(GarageInfo[i][GarageSize] == 1) { intoset = 2; }
if(GarageInfo[i][GarageSize] == 2) { intoset = 3; }
if(GarageInfo[i][GarageSize] == 3) { intoset = 1; }
if(GarageInfo[i][GarageLocked]) return SendClientMessage(playerid, GREY, "This garage is locked.");
if(IsPlayerInRangeOfPoint(playerid, 5.5, GarageInfo[i][GarageEnterX], GarageInfo[i][GarageEnterY], GarageInfo[i][GarageEnterZ]))
{
if(GetPlayerState(playerid) == 2)
{
vehicleid = GetPlayerVehicleID(playerid);
SetVehiclePos(vehicleid, GarageInfo[i][GarageInsideX], GarageInfo[i][GarageInsideY], GarageInfo[i][GarageInsideZ] + 0.4);
SetVehicleZAngle(vehicleid, GarageInfo[i][GarageInsideA]);
SetVehicleWorld(vehicleid, i);
SetVehicleInterior(vehicleid, intoset);
for(new j = 0; j < MAX_PLAYERS; j++)
{
if(IsPlayerInVehicle(j, vehicleid))
{
InCar[j] = vehicleid;
Seat[j] = GetPlayerVehicleSeat(j);
SetPlayerInterior(j, intoset);
SetPlayerVirtualWorld(j, i);
SetPVarInt(j, "InGarage", 1);
}
}
}
SetPlayerPosEx(playerid, GarageInfo[i][GarageInsideX], GarageInfo[i][GarageInsideY], GarageInfo[i][GarageInsideZ]);
SetPlayerFacingAngle(playerid, GarageInfo[i][GarageInsideA]);
SetPlayerInterior(playerid, intoset);
SetPlayerVirtualWorld(playerid, i);
if (vehicleid != 0)
{
for (new j = 0; j < MAX_PLAYERS; j++)
{
if (InCar[j] == 0) continue;
if (InCar[j] == vehicleid)
{
PutPlayerInVehicle(j, vehicleid, Seat[j]);
}
}
}
SetPVarInt(playerid, "InGarage", 1);
OnPlayerEnterGarage(playerid, i);
return 1;
}
else
{
SendClientMessage(playerid, GREY, " You are not near a garage.");
return 1;
}
}
return 1;
}
if(strcmp(cmd, "/exitgarage", true) == 0 || strcmp(cmd, "/exitga", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new Seat[MAX_PLAYERS], InCar[MAX_PLAYERS];
new i = GetPlayerVirtualWorld(playerid), vehicleid;
if(i == 0) return SendClientMessage(playerid, GREY, " You are not inside a garage.");
if(GarageInfo[i][GarageLocked]) return SendClientMessage(playerid, GREY, " You've been locked inside the garage, tough luck.");
if(IsPlayerInRangeOfPoint(playerid, 30.0, GarageInfo[i][GarageInsideX], GarageInfo[i][GarageInsideY], GarageInfo[i][GarageInsideZ]) && GetPlayerVirtualWorld(playerid) == i)
{
if(GetPlayerState(playerid) == 2)
{
vehicleid = GetPlayerVehicleID(playerid);
for(new j = 0; j < MAX_PLAYERS; j++)
{
if(IsPlayerInVehicle(j, vehicleid))
{
InCar[j] = vehicleid;
Seat[j] = GetPlayerVehicleSeat(playerid);
SetPlayerInterior(j, 0);
SetPlayerVirtualWorld(j, 0);
SetPVarInt(j, "InGarage", 0);
}
}
SetVehiclePos(vehicleid, GarageInfo[i][GarageExitX], GarageInfo[i][GarageExitY], GarageInfo[i][GarageExitZ]);
SetVehicleZAngle(vehicleid, GarageInfo[i][GarageExitA]);
SetVehicleWorld(vehicleid, 0);
SetVehicleInterior(vehicleid, 0);
}
SetPlayerPosEx(playerid, GarageInfo[i][GarageExitX], GarageInfo[i][GarageExitY], GarageInfo[i][GarageExitZ]);
SetPlayerFacingAngle(playerid, GarageInfo[i][GarageExitA]);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
if(vehicleid != 0)
{
for (new j = 0; j < MAX_PLAYERS; j++)
{
if (InCar[j] == 0) continue;
if (InCar[j] == vehicleid)
{
PutPlayerInVehicle(j, vehicleid, Seat[j]);
}
}
PutPlayerInVehicle(playerid, vehicleid, 0);
}
SetPVarInt(playerid, "InGarage", 0);
return 1;
}
else
{
SendClientMessage(playerid, GREY, " You are not near a garage exit.");
return 1;
}
}
return 1;
}

Pottus
30/10/2013, 09:31 PM
To be honest you have some really wacked out coding there so it doesn't surprise me your having issues with this system. To iterate that with your issue look at this.

new i = IsPlayerNearGarage(playerid) - When entering
new i = GetPlayerVirtualWorld(playerid) - When exiting

if(IsPlayerInRangeOfPoint(playerid, 30.0, GarageInfo[i][GarageInsideX], GarageInfo[i][GarageInsideY], GarageInfo[i][GarageInsideZ]) && GetPlayerVirtualWorld(playerid) == i)

1.) You don't need this && GetPlayerVirtualWorld(playerid) == i
2.) Virtualworlds is a shitty way to try and keep track of what array index to use
3.) Your dynamic system design is pretty bad

I'd make a number of changes:

1.) Use the streamer plugin and dynamic areas to keep an index of enter/exit points
2.) Create simplified commands that use common code built into functions
3.) Use a proper command processor

Songason
30/10/2013, 09:36 PM
Pottus;2762588']To be honest you have some really wacked out coding there so it doesn't surprise me your having issues with this system. To iterate that with your issue look at this.

new i = IsPlayerNearGarage(playerid) - When entering
new i = GetPlayerVirtualWorld(playerid) - When exiting

if(IsPlayerInRangeOfPoint(playerid, 30.0, GarageInfo[i][GarageInsideX], GarageInfo[i][GarageInsideY], GarageInfo[i][GarageInsideZ]) && GetPlayerVirtualWorld(playerid) == i)

1.) You don't need this && GetPlayerVirtualWorld(playerid) == i
2.) Virtualworlds is a shitty way to try and keep track of what array index to use
3.) Your dynamic system design is pretty bad

I'd make a number of changes:

1.) Use the streamer plugin and dynamic areas to keep an index of enter/exit points
2.) Create simplified commands that use common code built into functions
3.) Use a proper command processor

So you can't fix this? Lol.

Pottus
30/10/2013, 10:02 PM
I could fix it but, that isn't worth my time.... place a bandaid? Shit would I know with that messy code if it would work.

Songason
30/10/2013, 10:46 PM
Pottus;2762588']To be honest you have some really wacked out coding there so it doesn't surprise me your having issues with this system. To iterate that with your issue look at this.

new i = IsPlayerNearGarage(playerid) - When entering
new i = GetPlayerVirtualWorld(playerid) - When exiting

if(IsPlayerInRangeOfPoint(playerid, 30.0, GarageInfo[i][GarageInsideX], GarageInfo[i][GarageInsideY], GarageInfo[i][GarageInsideZ]) && GetPlayerVirtualWorld(playerid) == i)

1.) You don't need this && GetPlayerVirtualWorld(playerid) == i
2.) Virtualworlds is a shitty way to try and keep track of what array index to use
3.) Your dynamic system design is pretty bad

I'd make a number of changes:

1.) Use the streamer plugin and dynamic areas to keep an index of enter/exit points
2.) Create simplified commands that use common code built into functions
3.) Use a proper command processor

Pottus;2762621']I could fix it but, that isn't worth my time.... place a bandaid? Shit would I know with that messy code if it would work.

What's a bandaid?

Songason
30/10/2013, 10:59 PM
Anyone else who could help?

RayDcosta
31/10/2013, 06:59 AM
you have a bad script there.
u dont know how to do what [ul]pottus said, because u probably just copied it from somewhere.
and well if u do know how to,
then heres what u gotta do, for a temporary fix.
or what u can call a non destructive fix.
just change the co-ords of each entrance to match with each exit based on where uve placed them.
if u understand what im tryna say.
and use ZCMD for fucks sake, strcmp is WAY OLD and no one will work with u on this.
P.S: this is scripting help. people wont fix all ur issues, theyll only give u ideas. its for people who know to script but dont know what to do
Cheers :D

Songason
31/10/2013, 03:15 PM
you have a bad script there.
u dont know how to do what [ul]pottus said, because u probably just copied it from somewhere.
and well if u do know how to,
then heres what u gotta do, for a temporary fix.
or what u can call a non destructive fix.
just change the co-ords of each entrance to match with each exit based on where uve placed them.
if u understand what im tryna say.
and use ZCMD for fucks sake, strcmp is WAY OLD and no one will work with u on this.
P.S: this is scripting help. people wont fix all ur issues, theyll only give u ideas. its for people who know to script but dont know what to do
Cheers :D
I understand what you mean, but that will geve me alot of manual work.

Pottus
31/10/2013, 04:04 PM
I understand what you mean, but that will geve me alot of manual work.

People don't script because it's easy we script because it's hard and once it gets easy we've learned enough to move on to more advanced concepts.

Songason
31/10/2013, 06:47 PM
Pottus;2763469']People don't script because it's easy we script because it's hard and once it gets easy we've learned enough to move on to more advanced concepts.
Thanks for your advice and shit, but I learn in a different manner than you guys.