SA-MP Forums Archive
bug in my park command? - 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: bug in my park command? (/showthread.php?tid=529072)



bug in my park command? - ben4uka - 31.07.2014

hi, i made that command:
Код:
if(!strcmp(cmd, "/parkcar", true))
	{
	    if(!dini_Int(GetFile(playerid), "HaveCar")) return SendClientMessage(playerid,red,"You dont have car");
	    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You are not in a car");
		if(vehicleid != CarID(playerid)) return SendClientMessage(playerid,red,".This is not your car");
		
		new Float:X,Float:Y,Float:Z,Float:A;
		GetVehiclePos(vehicleid, X, Y, Z);
		GetVehicleZAngle(vehicleid, A);
		dini_FloatSet(VFile(vehicleid), "ParkX", X);
		dini_FloatSet(VFile(vehicleid), "ParkY", Y);
		dini_FloatSet(VFile(vehicleid), "ParkZ", Z);
		dini_FloatSet(VFile(vehicleid), "ParkA", A);
		SetVehicleToRespawn(vehicleid);
		
		SendClientMessage(playerid,lgreen,".You parked your car");
	    return 1;
	}
and in OnVehicleSpawn:
Код:
if(dini_Float(VFile(vehicleid), "ParkX"))
	{
		SetVehiclePos(vehicleid, dini_Float(VFile(vehicleid), "ParkX"), dini_Float(VFile(vehicleid), "ParkY"), dini_Float(VFile(vehicleid), "ParkZ"));
		SetVehicleZAngle(vehicleid, dini_Float(VFile(vehicleid), "ParkA"));
	}
It is spawning the car in the X, Y, but the Angle is messed up it goes to other direction about 78 degrees..
How can i fix it?


Re: bug in my park command? - Jack_Leslie - 31.07.2014

Why don't you just create the vehicle in that part of the code instead of setting the position?


Re: bug in my park command? - ben4uka - 31.07.2014

Quote:
Originally Posted by Jack_Leslie
Посмотреть сообщение
Why don't you just create the vehicle in that part of the code instead of setting the position?
its my vehicle system, i made /buycar command then i made that parkcar command so people could park the car in the place they want it to be..


Re: bug in my park command? - Jack_Leslie - 31.07.2014

Quote:
Originally Posted by ben4uka
Посмотреть сообщение
its my vehicle system, i made /buycar command then i made that parkcar command so people could park the car in the place they want it to be..
Do you have enum variables that you store the information in?
Example:
Код:
VehicleInfo[vehicleid][ParkX]



Re: bug in my park command? - ben4uka - 31.07.2014

Quote:
Originally Posted by Jack_Leslie
Посмотреть сообщение
Do you have enum variables that you store the information in?
Example:
Код:
VehicleInfo[vehicleid][ParkX]
Nope.


Re: bug in my park command? - Jack_Leslie - 31.07.2014

Quote:
Originally Posted by ben4uka
Посмотреть сообщение
Nope.
My suggestion to possibly fix your bug and make your code more effective, is to make it so you do. Then, instead of always opening, editing and closing a file, you just set the variables, and only need to open and close the file when you load and save. It should fix your bug and (in my opinion) make the system more effective.


Re : bug in my park command? - ManuelNeuer - 31.07.2014

nvm...


Re: bug in my park command? - Clad - 31.07.2014

pawn Код:
if(!strcmp(cmd, "/parkcar", true))
{
            new vehicle;
            vehicle = GetPlayerVehicleID(playerid);
        if(!dini_Int(GetFile(playerid), "HaveCar")) return SendClientMessage(playerid,red,"You dont have car");
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You are not in a car");
        if(vehicleid != CarID(playerid)) return SendClientMessage(playerid,red,".This is not your car");
       
        new Float:X,Float:Y,Float:Z;
                new Float:angle;
        GetVehiclePos(vehicleid, X, Y, Z);
                GetVehicleZAngle(currentveh, angle);
                SetVehicleZAngle(currentveh, angle);
        dini_FloatSet(VFile(vehicleid), "ParkX", X);
        dini_FloatSet(VFile(vehicleid), "ParkY", Y);
        dini_FloatSet(VFile(vehicleid), "ParkZ", Z);
        SetVehicleToRespawn(vehicleid);
       
        SendClientMessage(playerid,lgreen,".You parked your car");
        return 1;
    }



Re: bug in my park command? - ben4uka - 31.07.2014

Quote:
Originally Posted by Clad
Посмотреть сообщение
pawn Код:
if(!strcmp(cmd, "/parkcar", true))
{
            new vehicle;
            vehicle = GetPlayerVehicleID(playerid);
        if(!dini_Int(GetFile(playerid), "HaveCar")) return SendClientMessage(playerid,red,"You dont have car");
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You are not in a car");
        if(vehicleid != CarID(playerid)) return SendClientMessage(playerid,red,".This is not your car");
       
        new Float:X,Float:Y,Float:Z;
                new Float:angle;
        GetVehiclePos(vehicleid, X, Y, Z);
                GetVehicleZAngle(currentveh, angle);
                SetVehicleZAngle(currentveh, angle);
        dini_FloatSet(VFile(vehicleid), "ParkX", X);
        dini_FloatSet(VFile(vehicleid), "ParkY", Y);
        dini_FloatSet(VFile(vehicleid), "ParkZ", Z);
        SetVehicleToRespawn(vehicleid);
       
        SendClientMessage(playerid,lgreen,".You parked your car");
        return 1;
    }
Nope. not working.


Re: bug in my park command? - Clad - 31.07.2014

pawn Код:
if(!strcmp(cmd, "/parkcar", true))
{
            new vehicle;
            vehicle = GetPlayerVehicleID(playerid);
        if(!dini_Int(GetFile(playerid), "HaveCar")) return SendClientMessage(playerid,red,"You dont have car");
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You are not in a car");
        if(vehicleid != CarID(playerid)) return SendClientMessage(playerid,red,".This is not your car");
       
        new Float:X,Float:Y,Float:Z;
                new Float:angle;
        GetVehiclePos(vehicle, X, Y, Z);
                GetVehicleZAngle(vehicle, angle);
                SetVehicleZAngle(vehicle, angle);
        dini_FloatSet(VFile(vehicleid), "ParkX", X);
        dini_FloatSet(VFile(vehicleid), "ParkY", Y);
        dini_FloatSet(VFile(vehicleid), "ParkZ", Z);
        SetVehicleToRespawn(vehicleid);
       
        SendClientMessage(playerid,lgreen,".You parked your car");
        return 1;
    }