SA-MP Forums Archive
Job problem - 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: Job problem (/showthread.php?tid=600625)



Job problem - AnoTek - 10.02.2016

I made a drug dealer job and i have a problem with him. I made a timer(3 minutes) and i put it on OnPlayerExitVehicle

Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
	if(drugdj[playerid] == 1)
	{
		SetTimerEx("drugsss", 180000, 0, "i", playerid);
	    vehEngine[vehicleid] = 0;
	    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
	    SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
	    SetPVarInt(playerid, "Engine", 0);
	    DestroyVehicle(vehicleid);
		SendClientMessage(playerid,COLOR_LIGHTBLUE,"JOB: You lose the race because you get out of the car!");
		DisablePlayerCheckpoint(playerid);
	}
	return 1;
}
The public of the timer:
Код:
forward drugsss(playerid);
public drugsss(playerid)
{
	drugdj[playerid] = 0;
	SendClientMessage(playerid,COLOR_WHITE,"{FFB870}Now you can make another race!");
	return 1;
}
And this is the /work command:
Код:
CMD:work(playerid, params[])
{
	new rand = random(sizeof(CursaRandomDrug));
    if(IsPlayerInRangeOfPoint(playerid,7.0,-2546.0862,9.2330,16.4219))
   	{
		if(PlayerInfo[playerid][pJob] >= 1)
	    {
			if(drugdj[playerid] == 1) return SendClientMessage(playerid,COLOR_WHITE,"{FFB870}Wait 3 minutes to start another race!");
			{
				new Float:x, Float:y, Float:z, Float:a;
				GetPlayerPos(playerid, x,y,z); 
				GetPlayerFacingAngle(playerid, a);
				new vehicleid = CreateVehicle(459, x+3,y,z, a, -1, -1, -1);
				SetPlayerCheckpoint(playerid, CursaRandomDrug[rand][0], CursaRandomDrug[rand][1], CursaRandomDrug[rand][2], CursaRandomDrug[rand][3]);
				PutPlayerInVehicle(playerid, vehicleid, 0);
				SendClientMessage(playerid, COLOR_LIGHTBLUE, "JOB: Deliver the drugs to set destination on the map!");
				drugdj[playerid] = 1;
			}	
		}
	}
	return 1;
}
When i exit the vehicle it said "You lose the race because you get out of the car" the timer works but the problem is when i spawn another car to ride with it and i get out it said "You lose the race because you get out of the car"..

How can i solve this?


Re: Job problem - Kitten - 10.02.2016

OnPlayerExitVehicle simply just make the drugdj[playerid] variable to drugdj[playerid] = -1; Because three minutes later it'll set the variable to zero, if you still get in another vehicle then exit it'll still assume it's drugdj[playerid] = 1;


Re: Job problem - Joron - 10.02.2016

Dude...Another topic with the same thing? https://sampforum.blast.hk/showthread.php?tid=600576


Re: Job problem - AnoTek - 10.02.2016

Quote:
Originally Posted by Joron
Посмотреть сообщение
Dude...Another topic with the same thing? https://sampforum.blast.hk/showthread.php?tid=600576
Nope. This is other problem.


Re: Job problem - Riddy - 10.02.2016

AFAIK, you are trying to say if you spawn another vehicle in, you get in it and get out of it causing for that message to pop-up because the variable drugdj is set to 1?

If so, you need to inform that script that the user is on a job, therefore you should create a variable that tells the script that the user is actually not on a job and it should skip this function completely, therefore the `if` statement should become:

Код:
if(drugdj[playerid] == 1 && onJob[playerid] == 1) ...
Make sure to set the onJob[playerid] back to 0 when that statement parameters are correct....