public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { if(gMissionInt[playerid] == 1) { LastOrCurrentVeh[playerid] = vehicleid; } return 1; }
public OnPlayerExitVehicle(playerid, vehicleid) { if(gMissionInt[playerid] == 1) { LastOrCurrentVeh[playerid] = vehicleid; } return 1; }
gMissionInt[playerid] = 1; truckchecktime = SetTimerEx("TruckCheck", 1000, true, "i", playerid);
forward TruckCheck(playerid); public TruckCheck(playerid) { new str[128]; if (!IsPlayerInAnyVehicle(playerid) || !IsTrailerAttachedToVehicle(LastOrCurrentVeh[playerid])) { truckTime[playerid]++; format(str, sizeof(str), "Get back in your truck! ~n~or~n~Reconnect your trailer! ~n~(%d)", 30 - truckTime[playerid]); GameTextForPlayer(playerid, str, 1000, 3); PlayerPlaySound(playerid,1056,0.0,0.0,0.0); if (truckTime[playerid] >= 30) { KillTimer(truckchecktime); StopPlayerJob(playerid); SendClientMessage(playerid, COLOR_LIGHTGREEN, "You failed the mission!"); truckTime[playerid] = 0; } return 1; } return 0; }
Originally Posted by DerickClark
In command
gMissionInt[playerid] = 1; truckchecktime = SetTimerEx("TruckCheck", 1000, true, "i", playerid); |
whats the right timer for that code? and yes its only called for id 0.
|
Submitted code is valid but you have not given the instruction code where the timer is. Most likely there is error.
Such ridiculous errors occur often due to fatigue, when a programmer ceases to understand simple things. Tip: Take a break to rest. |
CMD:mission(playerid, params[]) {
gMissionInt[playerid] = 1;
truckchecktime = SetTimerEx("TruckCheck", 1000, true, "i", playerid);
return 1;
}
I have it
PHP Code:
|
forward TruckCheck(playerid);
public TruckCheck(playerid)
{
new str[128];
new vehicleid = GetPlayerVehicleID(playerid);
if (!vehicleid || !IsTrailerAttachedToVehicle(vehicleid)) {
truckTime[playerid]++;
format(str, sizeof(str), "Get back in your truck! ~n~or~n~Reconnect your trailer! ~n~(%d)", 30 - truckTime[playerid]);
GameTextForPlayer(playerid, str, 1000, 3);
PlayerPlaySound(playerid,1056,0.0,0.0,0.0);
if (truckTime[playerid] >= 30) {
KillTimer(truckchecktime);
StopPlayerJob(playerid);
SendClientMessage(playerid, COLOR_LIGHTGREEN, "You failed the mission!");
truckTime[playerid] = 0;
}
return 1;
}
return 0;
}