[PEDIDO/AJUDA] Tempo para digitar outro comando -
Delete_ - 14.02.2012
Eu queria que o player digita-se o comando /trabalhar somente apуs 10 segundos, tipo, "vocк sу pode repetir o comando /trabalhar depois de 10 segundos". comando:
pawn Код:
COMMAND:trabalhar(playerid, params[])
{
// Send the command to all admins so they can see it
SendAdminText(playerid, "/trabalhar", params);
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// First check if the player already has a job
if (APlayerData[playerid][JobStarted] == false)
{
// Check the player's class
switch (APlayerData[playerid][PlayerClass])
{
case ClassTruckDriver:
{
// Get the id of the convoy (if the player is in a convoy)
new Convoy = APlayerData[playerid][ConvoyID];
// Check if the player is part of a convoy AND is not the leader
if ((APlayerData[playerid][InConvoy] == true) && (AConvoys[Convoy][Members][0] != playerid))
{
// Let the player know he's not the leader of his convoy and cannot start a job
SendClientMessage(playerid, 0xFF0000FF, "Vocк nгo й o motorista do caminhгo!");
// Exit the function
return 1;
}
// A convoy-leader proceeds here, and also a normal player (no convoy-member)
// Check if the player is the driver of a vehicle
if (GetPlayerVehicleSeat(playerid) == 0)
{
// Check if the player is inside a valid trucking vehicle
switch (GetVehicleModel(GetPlayerVehicleID(playerid)))
{
case VehicleFlatbed, VehicleDFT30, VehicleCementTruck: // Flatbed, DFT-30, CementTruck
if (APlayerData[playerid][TruckerLicense] == 1) // Check if the player has acquired a truckers license
ShowPlayerDialog(playerid, DialogTruckerJobMethod, DIALOG_STYLE_LIST, "Selecione um mйtodo:", "Configurar a sua prуpria carga e rota\r\nCarga automбtica", "Selecionar", "Cancelar");
else
Trucker_StartRandomJob(playerid); // Start a random job
case VehicleLineRunner, VehicleTanker, VehicleRoadTrain: // Player is driving a truck which needs a trailer
if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))) // Check if there is a trailer attached
if (APlayerData[playerid][TruckerLicense] == 1) // Check if the player has acquired a truckers license
ShowPlayerDialog(playerid, DialogTruckerJobMethod, DIALOG_STYLE_LIST, "Selecione um mйtodo:", "Configurar a sua prуpria carga e rota\r\nCarga automбtica", "Selecionar", "Cancelar");
else
Trucker_StartRandomJob(playerid); // Start a random job
else
SendClientMessage(playerid, 0xFF0000FF, "Vocк precisa de um reboque para iniciar um trabalho");
default: SendClientMessage(playerid, 0xFF0000FF, "Vocк precisa ser o condutor de um veнculo de transporte rodoviбrio para iniciar um trabalho");
}
}
else
SendClientMessage(playerid, 0xFF0000FF, "Vocк precisa ser o condutor de um veнculo de transporte rodoviбrio para iniciar um trabalho");
}
case ClassBusDriver:
{
// Check if the player is the driver of a vehicle
if (GetPlayerVehicleSeat(playerid) == 0)
if (GetVehicleModel(GetPlayerVehicleID(playerid)) == VehicleCoach) // Check if the player is inside a valid busdriver vehicle
if (APlayerData[playerid][BusLicense] == 1) // Check if the player has acquired a busdriver license
ShowPlayerDialog(playerid, DialogBusJobMethod, DIALOG_STYLE_LIST, "Selecione um mйtodo:", "Configurar a sua prуpria rota\r\nRota automбtica", "Selecionar", "Cancelar");
else
BusDriver_StartJob(playerid, random(sizeof(ABusRoutes))); // Start a random job
else
SendClientMessage(playerid, 0xFF0000FF, "Vocк precisa ser o motorista de um фnibus para iniciar um trabalho");
else
SendClientMessage(playerid, 0xFF0000FF, "Vocк precisa ser o motorista de um фnibus para iniciar um trabalho");
}
case ClassPilot:
{
// Check if the player is the driver of a vehicle
if (GetPlayerVehicleSeat(playerid) == 0)
{
// Check if the player is inside a valid piloting vehicle
switch (GetVehicleModel(GetPlayerVehicleID(playerid)))
{
case VehicleShamal, VehicleNevada, VehicleMaverick, VehicleCargobob: // Plane (Shamal), Plane (Nevada), helicopter (Maverick)
Pilot_StartRandomJob(playerid); // Start a random piloting job
default: SendClientMessage(playerid, 0xFF0000FF, "Vocк precisa ser um piloto para iniciar um trabalho");
}
}
else
SendClientMessage(playerid, 0xFF0000FF, "Vocк precisa ser um piloto para iniciar um trabalho");
}
case ClassMafia:
{
// Check if the player is the driver of a vehicle
if (GetPlayerVehicleSeat(playerid) == 0)
{
// Check if the player is inside a valid piloting vehicle
switch (GetVehicleModel(GetPlayerVehicleID(playerid)))
{
case VehicleSandKing, VehicleMoonbeam: // Sangking, Moonbeam
Mafia_StartRandomJob(playerid); // Start a random mafia job
default: SendClientMessage(playerid, 0xFF0000FF, "Vocк precisa ser o condutor de um veнculo da mбfia para iniciar um trabalho");
}
}
else
SendClientMessage(playerid, 0xFF0000FF, "Vocк precisa ser o condutor de um veнculo da mбfia para iniciar um trabalho");
}
case ClassCourier:
{
// Check if the player is the driver of a vehicle
if (GetPlayerVehicleSeat(playerid) == 0)
{
// Check if the player is inside a valid courier vehicle
switch (GetVehicleModel(GetPlayerVehicleID(playerid)))
{
case VehicleBurrito, VehicleFaggio, VehicleBenson: // Van (Burrito), bike (Faggio)
Courier_StartJob(playerid); // Start a random courier job
default: SendClientMessage(playerid, 0xFF0000FF, "Vocк precisa ser o condutor de um veнculo dos correios para iniciar um trabalho");
}
}
else
SendClientMessage(playerid, 0xFF0000FF, "Vocк precisa ser o condutor de um veнculo dos correios para iniciar um trabalho");
}
case ClassRoadWorker:
{
// Check if the player is the driver of a vehicle
if (GetPlayerVehicleSeat(playerid) == 0)
{
// Check if the player is inside a valid courier vehicle
switch (GetVehicleModel(GetPlayerVehicleID(playerid)))
{
case VehicleUtilityVan, VehicleTowTruck: // Utility Van, Towtruck
Roadworker_StartRandomJob(playerid); // Start a random roadworker job
default: SendClientMessage(playerid, 0xFF0000FF, "Vocк precisa ser o condutor de um veнculo Operбrio para iniciar um trabalho");
}
}
else
SendClientMessage(playerid, 0xFF0000FF, "Vocк precisa ser o condutor de um veнculo roadworker Operбrio iniciar um trabalho");
}
default: SendClientMessage(playerid, 0xFF0000FF, "Sua skin nгo pode fazer todos os trabalhos");
}
}
else // Send a message to let the player know he already has a job
SendClientMessage(playerid, 0xFF0000FF, "Vocк jб estб trabalhando");
}
else
return 0;
// Let the server know that this was a valid command
return 1;
}
Re: [PEDIDO/AJUDA] Tempo para digitar outro comando -
Hard` - 14.02.2012
SetTimer Wiki SA-MP
Veja esse tуpico, com o mesmo assunto, talvez ele possa te ajudar:
[AJUDA]Settimer em Comando
Re: [PEDIDO/AJUDA] Tempo para digitar outro comando -
zbt - 14.02.2012
pawn Код:
//topo
new aguarde[MAX_PLAYERS];
//no comando
if(GetTickCount() - aguarde[playerid] < 10000){
SendClientMessage(playerid,-1,"vocк sу pode repetir o comando /trabalhar depois de 10 segundos.");
return 1;
}
//quando ele for executado
aguarde[playerid] = GetTickCount();
Re: [PEDIDO/AJUDA] Tempo para digitar outro comando -
Hard` - 14.02.2012
Ou se quiser usar SetTimer,
Eu acho que dessa forma da:
No topo
pawn Код:
new CmdUsado[MAX_PLAYERS];
Dentro do comando
pawn Код:
if(CmdUsado[playerid]==1) return SendClientMessage(playerid,COR_AQUI,"Espere um tempo para re-utilizar o comando!");
CmdUsado[playerid]=1;
SetTimerEx("CmdUse",60000,false,"i",palyerid);
SetTimerEx
No
topo
pawn Код:
forward CmdUse(playerid);
Crie uma
public
pawn Код:
public CmdUse(playerid) {
CmdUsado[playerid]=0;
return 1;
}
No
OnPlayerDisconnect
Espero ter ajudado.
Re: [PEDIDO/AJUDA] Tempo para digitar outro comando -
Ricop522 - 14.02.2012
nгo precisa disso tudo.
pawn Код:
SetPVarInt(playerid, "cmdT", gettime()+SEGUNDOS_PARA_COMANDO); // setando a variavel que armazena os segundos que ele pode usar o comando
//Para checar se ele pode usar o comando
if(GetPVarInt(playerid, "cmdT") < gettime()) return SendClientMessage(playerid, -1, "Aguarde SEGUNDOS_PARA_COMANDOS para usar esse comando novamente.");
NГO USE GETTICKCOUNT !