SA-MP Forums Archive
Help - 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 (/showthread.php?tid=601977)



Help - Banditul18 - 29.02.2016

Hello i try to make something like when you in a truck and trailer is attached to create a checkpoint but it isn't working
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	new vID = GetPlayerVehicleID(playerid);
	if(newstate == PLAYER_STATE_DRIVER)
	{
		if(vID == 403 || 514 || 515)
		{
			if(IsTrailerAttachedToVehicle(vID))
			{
				new trailerid = GetVehicleTrailer(vID);
				new trailermodel = GetVehicleModel(trailerid);
				if(trailermodel == 435 || 450 || 584)
				{
					//new WorkCP = CreateDynamicCP(1588.8866,715.2956,10.8203,3.0,-1,-1,playerid,100.0);
					SetPlayerCheckpoint(playerid, 1588.8866,715.2956,10.8203, 3.0);
				}
			}
		}
	}
	else if(newstate == PLAYER_STATE_ONFOOT)
	{
		DisablePlayerCheckpoint(playerid);
	}
	return 1;
}
Any solution?


Re: Help - AdmBot - 29.02.2016

Use: if(vID == 403 || vID == 514 || vID == 515) and if(trailermodel == 435 || trailermodel == 450 || trailermodel == 584)


Re: Help - MicroKyrr - 01.03.2016

Remove
Код:
SetPlayerCheckpoint(playerid, 1588.8866,715.2956,10.8203, 3.0);
And change
Код:
DisablePlayerCheckpoint(playerid);
To
Код:
DestroyDynamicCP(checkpointid);
It will look like this
PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    new 
vID GetPlayerVehicleID(playerid);
    if(
newstate == PLAYER_STATE_DRIVER)
    {
        if(
vID == 403 || 514 || 515)
        {
            if(
IsTrailerAttachedToVehicle(vID))
            {
                new 
trailerid GetVehicleTrailer(vID);
                new 
trailermodel GetVehicleModel(trailerid);
                if(
trailermodel == 435 || 450 || 584)
                {
                    new 
WorkCP CreateDynamicCP(1588.8866,715.2956,10.8203,3.0,-1,-1,playerid,100.0);
                }
            }
        }
    }
    else if(
newstate == PLAYER_STATE_ONFOOT)
    {
        
DestroyDynamicCP(WorkCP);
    }
    return 
1;




Re: Help - Banditul18 - 01.03.2016

Neither work, i tried both but the checkpoint is not creating....Thanks for helping anyway....


Re: Help - adammal - 01.03.2016

You are checking for the model here
if(vID == 403 || 514 || 515)

Not for individual vehicle ID's
Add in
new vModel = GetVehicleModel(vID);
and check
if(vModel == 403 || 514 || 515)


Re: Help - Banditul18 - 01.03.2016

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	new vID = GetPlayerVehicleID(playerid);
	new vModel = GetVehicleModel(vID);
	if(newstate == PLAYER_STATE_DRIVER)
	{
		SCM(playerid, -1,"Ping");
		if(vModel == 403 || 514 || 515)
		{
			SCM(playerid, -1,"Match");
			if(IsTrailerAttachedToVehicle(vID))
			{
				SCM(playerid, -1,"Trailer");
				new trailerid = GetVehicleTrailer(vID);
				new trailermodel = GetVehicleModel(trailerid);
				if(trailermodel == 435 || 450 || 584)
				{
					//new WorkCP = CreateDynamicCP(1588.8866,715.2956,10.8203,3.0,-1,-1,playerid,100.0);
					SetPlayerCheckpoint(playerid, 1588.8866,715.2956,10.8203, 3.0);
					SCM(playerid, -1,"Pong");
				}
			}
		}
	}
	else if(newstate == PLAYER_STATE_ONFOOT)
	{
		DisablePlayerCheckpoint(playerid);
	}
	return 1;
}
I've made this , just something like deubuging, but from the IsTrailerAttachedToVehicle is not calling, i put in wrong callback?


Re: Help - adammal - 02.03.2016

Its only going to be called if you get into a truck that already has a trailer attached.