#1

When 2 players do the work, if one ends before the other, the timer is cleared for 2. I do not know if I explain myself well.

Код:
CMD:tomar(playerid, params[])
{
    new opcion[32];
    if(sscanf(params, "s[32]", opcion))
    {
	SendClientMessage(playerid, -1, "{ffa500}[INFO]: {ffffff}El comando es {ffa500}/tomar <OPCIÓN>");
	return 1;
    }
    if(IsPlayerConnected(playerid))
    {
        if (strcmp(opcion, "pizza", true) == 0)
        {
       		if(GetPVarInt(playerid,"PIZZA_ENTREGACP")) return SendClientMessage(playerid, -1 ,"You can not deliver now.");
        	{
				new vehicleid = GetPlayerVehicleID(playerid);
				if(iVeh[vehicleid][vWork] != PizzaBoy) return SendClientMessage(playerid, -1,"Take a pizza bike.");
				{
				    if(!IsPlayerInRangeOfPoint(playerid, 2.0, 2124.6516,-1806.6782,13.1498)) return SendClientMessage(playerid, -1,"You have to be in the window");
				    {
						new rand = random(sizeof(PizzaCheck));
						new str[50];
						format(str, sizeof(str), "...", PizzaTime);
		      			PlayerTextDrawSetString(playerid, pizza_time[playerid], str);
						SetPVarInt(playerid,"PIZZA_GOCP", 1);
						SetPVarInt(playerid, "PIZZA_BIKE", VehicleID);
						SetPlayerCheckpoint(playerid, PizzaCheck[rand][0],PizzaCheck[rand][1],PizzaCheck[rand][2],PizzaCheck[rand][3]);
						TimerPizza[playerid] = SetTimerEx("PizzaTimer", 1000, true, "i", playerid);
						PizzaTime[playerid] = 90+random(140);
						PlayerTextDrawShow(playerid, pizza_time[playerid]);
						PlayerTextDrawShow(playerid, pizza_text[playerid]);
						PlayerTextDrawShow(playerid, pizza_box[playerid]);
						PizzaBox = CreateObject(1582, 0, 0, 0, 0, 0, 0);
						AttachObjectToVehicle(PizzaBox, VehicleID, -0.02970, -0.99190, 0.55320, 0.0, 0.0, 0.0);
					}
				}
        	}
        }
	}
	return 1;
}


forward PizzaTimer(playerid);
public PizzaTimer(playerid)
{
	PizzaTime[playerid]--;
	new str[50];
	format(str, sizeof(str), "%ds", PizzaTime);
 	PlayerTextDrawSetString(playerid, pizza_time[playerid], str);
	if(PizzaTime[playerid] == 0)
	{
		DisablePlayerCheckpoint(playerid);
		DeletePVar(playerid,"PIZZA_GOCP");
		DeletePVar(playerid, "PIZZA_BIKE");
		DeletePVar(playerid, "PIZZA_RETURNCP");
		DestroyObject(PizzaBox);
		PlayerTextDrawHide(playerid, pizza_time[playerid]);
		PlayerTextDrawHide(playerid, pizza_text[playerid]);
 		PlayerTextDrawHide(playerid, pizza_box[playerid]);
		KillTimer(TimerPizza[playerid]);
	}
	return 1;
}
Reply
#2

I'd say use a checkpoint at the location where the player finishes the job.

Once a player enters that checkpoint, use OnPlayerEnterCheckpoint to determine a winner (playerid being the winner, you'd just have to remove the checkpoint for the other player), kill the timer and give the winner their reward.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)