SA-MP Forums Archive
set time after each hour. - 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: set time after each hour. (/showthread.php?tid=416548)



set time after each hour. - PaulDinam - 17.02.2013

How do I make a check if a hour has passed and eventually it will SetWorldTime


Re: set time after each hour. - DaRk_RaiN - 17.02.2013

A timer?
pawn Код:
SetTimer("WorldTimer",1000*60*60,1);//Should be put in OnGameModeInIt call back.
pawn Код:
//If you don't know what this is, put it at the bottom of the script.
forward WorldTimer();
public WorldTimer()
{
SetWorldTimer(0);//Your choice.
}



Re: set time after each hour. - PaulDinam - 17.02.2013

but if I start the game mode in , for example: 12:59
the timer won't get that it's 13:00 now because it's only 1 minute.

another question:

I got these commands, but the "No such vehicle." if statement doesn't work.

pawn Код:
CMD:getcar(playerid, params[])
{
    new vehicle, Float:x, Float:y, Float:z;
    if(!CheckAdmin(playerid, ADMIN_LEVEL_1)) return NotAuthMSG(playerid);
    if(sscanf(params,"d",vehicle)) return SyntaxMSG(playerid, "/getcar [vehicleid]");
    if(vehicle > MAX_VEHICLES) return SCM(playerid, -1, "No such vehicle.");
    GetPlayerPos(playerid, x, y, z);
    SetVehiclePos(vehicle, x, y+4, z);
    return 1;
}

CMD:gotocar(playerid, params[])
{
    new vehicle, Float:x, Float:y, Float:z;
    if(!CheckAdmin(playerid, ADMIN_LEVEL_1)) return NotAuthMSG(playerid);
    if(sscanf(params,"d",vehicle)) return SyntaxMSG(playerid, "/gotocar [vehicleid]");
    if(vehicle > MAX_VEHICLES) return SCM(playerid, -1, "No such vehicle.");
    GetVehiclePos(vehicle, x, y, z);
    PutPlayer(playerid, x+1, y+1, z);
    return 1;
}



Re: set time after each hour. - DaRk_RaiN - 17.02.2013

pawn Код:
CMD:getcar(playerid, params[])
{
    new vehicle, Float:x, Float:y, Float:z;
    if(!CheckAdmin(playerid, ADMIN_LEVEL_1)) return NotAuthMSG(playerid);
    if(sscanf(params,"d",vehicle)) return SyntaxMSG(playerid, "/getcar [vehicleid]");
    if(vehicle == INVALID_VEHICLE_ID) return SCM(playerid, -1, "No such vehicle.");
    GetPlayerPos(playerid, x, y, z);
    SetVehiclePos(vehicle, x, y+4, z);
    return 1;
}

CMD:gotocar(playerid, params[])
{
    new vehicle, Float:x, Float:y, Float:z;
    if(!CheckAdmin(playerid, ADMIN_LEVEL_1)) return NotAuthMSG(playerid);
    if(sscanf(params,"d",vehicle)) return SyntaxMSG(playerid, "/gotocar [vehicleid]");
    if(vehicle == INVALID_VEHICLE_ID) return SCM(playerid, -1, "No such vehicle.");
    GetVehiclePos(vehicle, x, y, z);
    PutPlayer(playerid, x+1, y+1, z);
    return 1;
}
P.S: For the timer thing, there are some FS's that set player realistic time, take a look at them.


Re: set time after each hour. - PaulDinam - 17.02.2013

Lol this doesn't work..l

pawn Код:
CMD:getcar(playerid, params[])
{
    new vehicle, Float:x, Float:y, Float:z;
    if(!CheckAdmin(playerid, ADMIN_LEVEL_1)) return NotAuthMSG(playerid);
    if(sscanf(params,"d",vehicle)) return SyntaxMSG(playerid, "/getcar [vehicleid]");
    if(vehicle == INVALID_VEHICLE_ID) return SCM(playerid, -1, "No such vehicle.");
    GetPlayerPos(playerid, x, y, z);
    SetVehiclePos(vehicle, x, y+4, z);
    SetVehicleVirtualWorld(vehicle, GetPlayerVirtualWorld(playerid));
    LinkVehicleToInterior(vehicle, GetInterior(playerid));
    return 1;
}
it doesn't show the No such vehicle msg.


Re: set time after each hour. - bensmart469 - 17.02.2013

PHP код:
CMD:getcar(playeridparams[])
{
    new 
vehicleFloat:xFloat:yFloat:z;
    if(!
CheckAdmin(playeridADMIN_LEVEL_1)) return NotAuthMSG(playerid);
    if(
sscanf(params,"i",vehicle)) return SyntaxMSG(playerid"/getcar [vehicleid]");
    if(
vehicle == INVALID_VEHICLE_ID) return SCM(playerid, -1"No such vehicle.");
    
GetPlayerPos(playeridxyz);
    
SetVehiclePos(vehiclexy+4z);
    
SetVehicleVirtualWorld(vehicleGetPlayerVirtualWorld(playerid));
    
LinkVehicleToInterior(vehicleGetInterior(playerid));
    return 
1;




Re: set time after each hour. - PaulDinam - 17.02.2013

I tried with "i", still..


Re: set time after each hour. - MP2 - 17.02.2013

It's going to look very ugly if the time suddenly jumps an hour forward. You should change it minute-by-minute.