SA-MP Forums Archive
[HELP] Saved automatic position of the vehicles - 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] Saved automatic position of the vehicles (/showthread.php?tid=522423)



[HELP] Saved automatic position of the vehicles - Shura - 27.06.2014

Hello, on my server I have a command to keep my car or someone else, but I want to achieve this is not using a command and is automatic, I could help?

Here I leave the command, if I need more I give, I need help please, give reputation at that time to help you take

Here the code


Код:
CMD:parkveh(playerid, params[])
{
if(Info[playerid][pVehicleKeysFrom] != INVALID_PLAYER_ID)
{
	new ownerid = Info[playerid][pVehicleKeysFrom];
	if(IsPlayerConnectedEx(ownerid))
	{
		new d = Info[playerid][pVehicleKeys];
		if(IsPlayerInVehicle(playerid, PlayerVehicleInfo[ownerid][d][pvId]))
		{
		    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessageEx(playerid, COLOR_GREY, "ERROR: Not a driver");
			new Float:x, Float:y, Float:z, Float:angle, Float:health;
			GetVehicleHealth(PlayerVehicleInfo[ownerid][d][pvId], health);
			PlayerVehicleInfo[ownerid][d][pvHealth] = health;
			if(Info[playerid][pLockCar] == GetPlayerVehicleID(playerid)) Info[playerid][pLockCar] = INVALID_VEHICLE_ID;
			GetVehiclePos(PlayerVehicleInfo[ownerid][d][pvId], x, y, z);
			GetVehicleZAngle(PlayerVehicleInfo[ownerid][d][pvId], angle);
			SurfingCheck(GetPlayerVehicleID(playerid));
			UpdatePlayerVehicleParkPosition(ownerid, d, x, y, z, angle, health);
			PutPlayerInVehicle(playerid, GetPlayerVehicleID(playerid), 0);
		 	SetPlayerArmedWeapon(playerid, 0);

			new string[29 + (MAX_PLAYER_NAME * 2)];
			format(string, sizeof(string), "* %s has parked the vehicle %s.", GetPlayerNameEx(playerid), GetPlayerNameEx(ownerid));
			ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            fVehSpeed[playerid] = 0.0;
			return 1;
		}
	}
}
for(new d = 0 ; d < MAX_PLAYERVEHICLES; d++)
{
	if(IsPlayerInVehicle(playerid, PlayerVehicleInfo[playerid][d][pvId]))
	{
	    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessageEx(playerid, COLOR_GREY, "You must be the driver.");
		new Float:x, Float:y, Float:z, Float:angle, Float:health;
		GetVehicleHealth(PlayerVehicleInfo[playerid][d][pvId], health);
		PlayerVehicleInfo[playerid][d][pvHealth] = health;
		if(Info[playerid][pLockCar] == GetPlayerVehicleID(playerid)) Info[playerid][pLockCar] = INVALID_VEHICLE_ID;
		GetVehiclePos(PlayerVehicleInfo[playerid][d][pvId], x, y, z);
		GetVehicleZAngle(PlayerVehicleInfo[playerid][d][pvId], angle);
		SurfingCheck(GetPlayerVehicleID(playerid));
		UpdatePlayerVehicleParkPosition(playerid, d, x, y, z, angle, health);
		PutPlayerInVehicle(playerid, PlayerVehicleInfo[playerid][d][pvId], 0);
		SetPlayerArmedWeapon(playerid, 0);

		new string[30 + (MAX_PLAYER_NAME * 2)];
		format(string, sizeof(string), "* %s your vehicle is parked.", GetPlayerNameEx(playerid));
		ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        fVehSpeed[playerid] = 0.0;
		return 1;
	}
}
SendClientMessageEx(playerid, COLOR_GREY, "You need to be inside your vehicle to do this.");
return 1;
}



Re: [HELP] Saved automatic position of the vehicles - Dziugsas - 27.06.2014

Just put this code under OnPlayerExitVehicle and your code will be triggered as soon as player leaves the vehicle.


Respuesta: [HELP] Saved automatic position of the vehicles - Shura - 27.06.2014

I know, but would not have to go "All" the code because the command has a function to other players, you could help me?


Re: [HELP] Saved automatic position of the vehicles - Dziugsas - 27.06.2014

So what you want to do?You want to save only for admins or what?


Respuesta: [HELP] Saved automatic position of the vehicles - Shura - 27.06.2014

No, I want you to keep in the same way I use the / park command, so that all users when leaving your vehicle is stored position, the issue is you have to change something in the function, and this lagearia server ? Hopefully I can help I will give +rep bro , pls :/


Re: [HELP] Saved automatic position of the vehicles - Dziugsas - 27.06.2014

As from the code i can see that is already saving vehicle pos for the owner.Whats wrong then?


Respuesta: [HELP] Saved automatic position of the vehicles - Shura - 27.06.2014

My problem is not how to accommodate the code to save the location only, no need to repair or of any message, understand? But without using command.

public OnPlayerExitVehicle(playerid, vehicleid)
{
//Here I need to adjust the code and do not know how
}


Re: [HELP] Saved automatic position of the vehicles - Dziugsas - 27.06.2014

pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(Info[playerid][pVehicleKeysFrom] != INVALID_PLAYER_ID)
    {
        new ownerid = Info[playerid][pVehicleKeysFrom];
        if(IsPlayerConnectedEx(ownerid))
        {
            new d = Info[playerid][pVehicleKeys];
            if(IsPlayerInVehicle(playerid, PlayerVehicleInfo[ownerid][d][pvId]))
            {
                if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessageEx(playerid, COLOR_GREY, "ERROR: Not a driver");
                new Float:x, Float:y, Float:z, Float:angle, Float:health;
                GetVehicleHealth(PlayerVehicleInfo[ownerid][d][pvId], health);
                PlayerVehicleInfo[ownerid][d][pvHealth] = health;
                if(Info[playerid][pLockCar] == GetPlayerVehicleID(playerid)) Info[playerid][pLockCar] = INVALID_VEHICLE_ID;
                GetVehiclePos(PlayerVehicleInfo[ownerid][d][pvId], x, y, z);
                GetVehicleZAngle(PlayerVehicleInfo[ownerid][d][pvId], angle);
                SurfingCheck(GetPlayerVehicleID(playerid));
                UpdatePlayerVehicleParkPosition(ownerid, d, x, y, z, angle, health);
                PutPlayerInVehicle(playerid, GetPlayerVehicleID(playerid), 0);
                SetPlayerArmedWeapon(playerid, 0);

                new string[29 + (MAX_PLAYER_NAME * 2)];
                format(string, sizeof(string), "* %s has parked the vehicle %s.", GetPlayerNameEx(playerid), GetPlayerNameEx(ownerid));
                ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                fVehSpeed[playerid] = 0.0;
                return 1;
            }
        }
    }
    for(new d = 0 ; d < MAX_PLAYERVEHICLES; d++)
    {
        if(IsPlayerInVehicle(playerid, PlayerVehicleInfo[playerid][d][pvId]))
        {
            if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessageEx(playerid, COLOR_GREY, "You must be the driver.");
            new Float:x, Float:y, Float:z, Float:angle, Float:health;
            GetVehicleHealth(PlayerVehicleInfo[playerid][d][pvId], health);
            PlayerVehicleInfo[playerid][d][pvHealth] = health;
            if(Info[playerid][pLockCar] == GetPlayerVehicleID(playerid)) Info[playerid][pLockCar] = INVALID_VEHICLE_ID;
            GetVehiclePos(PlayerVehicleInfo[playerid][d][pvId], x, y, z);
            GetVehicleZAngle(PlayerVehicleInfo[playerid][d][pvId], angle);
            SurfingCheck(GetPlayerVehicleID(playerid));
            UpdatePlayerVehicleParkPosition(playerid, d, x, y, z, angle, health);
            PutPlayerInVehicle(playerid, PlayerVehicleInfo[playerid][d][pvId], 0);
            SetPlayerArmedWeapon(playerid, 0);

            new string[30 + (MAX_PLAYER_NAME * 2)];
            format(string, sizeof(string), "* %s your vehicle is parked.", GetPlayerNameEx(playerid));
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            fVehSpeed[playerid] = 0.0;
            return 1;
        }
    }
    SendClientMessageEx(playerid, COLOR_GREY, "You need to be inside your vehicle to do this.");
    return 1;
    }
    return 1;
}
Working?


Respuesta: [HELP] Saved automatic position of the vehicles - Shura - 27.06.2014

That if they do, what I mean that would not be suitable for my type of server because this post would not be right, so I mean that opened to accommodate the code and that's what I get wrong.

Because it has to come out this message if you did not write any command, I mean?

Код:
SendClientMessageEx (playerid, COLOR_GREY, "You need to be inside your vehicle to do this.");
It is an example, similarly'll give + rep because I bothered to help. :/


Re: [HELP] Saved automatic position of the vehicles - Dziugsas - 27.06.2014

I really cant understand what you want.