Comando cada 20 Segundos
#1

Hola alguien sabe como puedo hacer que este comando "/ccar nr" se pueda hacer cada 20 segundos ? ?

como utilizo el settimer ? en este comando ?



if (!strcmp("/ccar nr", cmdtext, true))
{
new VehNrg, Float, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerVehicleID(playerid);
GetPlayerFacingAngle(playerid, a);
SpawnAuto[playerid] = CreateVehicle(522, x, y+2, z+1, a, -1, -1, -1);
SetVehicleVirtualWorld(VehNrg, GetPlayerVirtualWorld(playerid));
GivePlayerMoney(playerid, -500);
SendPlayerFormattedText(playerid," Has comprado un Vehiculo ($-500)", 0);


return 1;
}
Reply
#2

pawn Код:
SetTimerEx("HabilitarComando",20000,false,"i",playerid);//Esto dentro del comando
SetPVarInt(playerid,"NoPuedeComando",1);//Esto tambien

forward HabilitarComando(playerid);//Estos en cualquier otro lado
public HabilitarComando(playerid)
{
DeletePVar(playerid,"NoPuedeComando");
return 1;
}
Obviamente tienes que poner la condicional al comienzo del comando:
pawn Код:
if(GetPVarInt(playerid,"NoPuedeComando") == 1) return 0;
Reply
#3

pawn Код:
SetTimerEx("HabilitarComando",20000,false,"i",playerid);//Esto dentro del comando
SetPVarInt(playerid,"NoPuedeComando",1);//Esto tambien

forward HabilitarComando(playerid);//Estos en cualquier otro lado
public HabilitarComando(playerid)
{
DeletePVar(playerid,"NoPuedeComando");
return 1;
}
Obviamente tienes que poner la condicional al comienzo del comando:
pawn Код:
if(GetPVarInt(playerid,"NoPuedeComando") == 1) return 0;
Reply
#4

mбs simple asi

Код:
new TiempoEspera[MAX_PLAYERS];
if (!strcmp("/ccar nr", cmdtext, true))
{
if((gettime() - TiempoEspera[playerid]) < 20) return SendClientMessage(playerid, -1, "Debes esperar 20 segundos");
new VehNrg, Float, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerVehicleID(playerid);
GetPlayerFacingAngle(playerid, a);
SpawnAuto[playerid] = CreateVehicle(522, x, y+2, z+1, a, -1, -1, -1);
SetVehicleVirtualWorld(VehNrg, GetPlayerVirtualWorld(playerid));
GivePlayerMoney(playerid, -500);
SendPlayerFormattedText(playerid," Has comprado un Vehiculo ($-500)", 0);
TiempoEspera = gettime();
return 1;
}
Reply
#5

Quote:
Originally Posted by FelipeAndres
Посмотреть сообщение
mбs simple asi

Код:
new TiempoEspera[MAX_PLAYERS];
if (!strcmp("/ccar nr", cmdtext, true))
{
if((gettime() - TiempoEspera[playerid]) < 20) return SendClientMessage(playerid, -1, "Debes esperar 20 segundos");
new VehNrg, Float, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerVehicleID(playerid);
GetPlayerFacingAngle(playerid, a);
SpawnAuto[playerid] = CreateVehicle(522, x, y+2, z+1, a, -1, -1, -1);
SetVehicleVirtualWorld(VehNrg, GetPlayerVirtualWorld(playerid));
GivePlayerMoney(playerid, -500);
SendPlayerFormattedText(playerid," Has comprado un Vehiculo ($-500)", 0);
TiempoEspera = gettime();
return 1;
}
WTF que haces?? xD gettime es una funcion con parametros y estas declarando una matriz y le das valor a esa matriz como si fuera una variable...
Reply
#6

https://sampwiki.blast.hk/wiki/Gettime

puede usarse para obtener la cantidad de segundos transcurridos desde 1970
Код:
new Seconds = gettime();
printf("Seconds since midnight 1st January 1970: %d", Seconds);
fijate en el ejemplo, hay 2 formas de usarlo
Reply
#7

https://sampforum.blast.hk/showthread.php?pid=2547692#pid2547692
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)