Need help linking script with timer?
#1

Hey guys.
So i am making a vehicle buying system for my server and i got a problem: i want the system to take 10 min to spawn the car but im not being abble to find a way to link the command variable TModel wich is the input of the player on the command and the public:buyvehtime(playerid) wich is where the timer function is. I have everything good at the public:buyvehtime i just need the variables that are in the command to be in that with same values aswell. Can someone help me out please?
Reply
#2

so... can any 1 help me at all?
Reply
#3

When you use SetTimerEx, there are arguments supported in it which allows you to store static data from where the timer is initiated.

Example:
pawn Код:
SetTimerEx("OnPlayerVehicleSpawn", (10 * 60 * 1000) /*10 minutes*/, false, "ii", playerid, your_vehicle_model);
Reply
#4

Oh. Thanks man i apreciate it
Reply
#5

Hum it still says undefined symbol. Heres the code:
SetTimerEx("buyvehtime", 20000, false, "ii", playerid, TCarModel); // TCarModel is the model players input when they do /buycar (id)

at the end of the script:
public:buyvehtime(playerid)
{
for(new c=0;c<MAX_VEHICLES;c++)
{
DynamicCars[c][CarModel] = TCarModel;
DynamicCars[c][CarX] = 858.0088;
DynamicCars[c][CarY] = -587.1997;
DynamicCars[c][CarZ] = 18.0375;
DynamicCars[c][CarAngle] = 0.6107;
DynamicCars[c][CarColor1] = 1;
DynamicCars[c][CarColor2] = 1;
DynamicCars[c][comprado] = 1;
DynamicCars[c][buy] = 0;
DynamicCars[c][CarType] = 0;
DynamicCars[c][FactionCar] = 255;
DynamicCars[c][cPaintjob] = 999;
SaveDynamicCars();
DestroyVehicle(c+1);
SendClientMessage(playerid, COLOR_GREEN, "[SMS] Informamos por este meio que o seu veiculo encontra-se disponнvel na marinha de Palomino Creek.");
SendClientMessage(playerid, COLOR_GREY, "[SMS] Por favor levante o seu veiculo o mais cedo possivel. Obrigado pela compreensгo.");
CreateVehicle(DynamicCars[c][CarModel],DynamicCars[c][CarX],DynamicCars[c][CarY],DynamicCars[c][CarZ],DynamicCars[c][CarAngle],DynamicCars[c][CarColor1],DynamicCars[c][CarColor2], -1);
SetVehicleMatricula(c+1);
SetVehicleMatriculaLabel(c+1);
SetVehicleModifications(c+1);
SetVehicleToRespawn(c+1);
}
}
Reply
#6

You need to put this:
pawn Код:
SetTimerEx("buyvehtime", 20000, false, "ii", playerid, TCarModel);
In your command or within a class/callback/command/function to execute it.

And this isn't a valid syntax:
pawn Код:
public:
(we use a ' ' (space) instead of ':')
Reply
#7

and it is on the command ill post it here





if(strcmp(cmd, "/comprarveiculo", true) == 0)
{
if(PlayerToPoint(10.0, playerid,345.5447,160.1090,1014.1875))
{
if(PlayerInfo[playerid][pChave1] == 255 || PlayerInfo[playerid][pChave2] == 255 || PlayerInfo[playerid][pChave3] == 255 || PlayerInfo[playerid][pChave4] == 255 || PlayerInfo[playerid][pChave5] == 255 || PlayerInfo[playerid][pChave6] == 255)
{
for(new i = 0; i < sizeof(Businesses); i++)
{
if(PlayerToPoint(25.0, playerid,Businesses[i][ExitX], Businesses[i][ExitY], Businesses[i][ExitZ]))
{
if(GetPlayerVirtualWorld(playerid) == i)
{
if(Businesses[i][BizType] == 9)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "*{C8C8C8} Comando:{FFFFFF} /comprarveiculo [ID do Modelo do Veiculo]");
return 1;
}
new TCarModel = strval(tmp);
for(new c=0;c<MAX_VEHICLES;c++)
{
if(DynamicCars[c][comprado] == 0) // Nгo comprado
{
if(DynamicCars[c][valor] == 0) // Sem Preзo
{
if(DynamicCars[c][buy] == 1) // Para venda
{
if(DynamicCars[c][CarModel] == 481)
{
if(IsValidModel(TCarModel))
{
if( TCarModel == 509 || TCarModel == 481|| TCarModel == 510)
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "*{FF0000} Erro:{FFFFFF} Modelo Invбlido.");
return 1;
}
new valorveiculo = TCarModel-400;
new precoveiculo = VehiclePrices[valorveiculo][0];
if (PlayerInfo[playerid][pVipActive] == 0 && precoveiculo <= GetPlayerEuros(playerid) || PlayerInfo[playerid][pVipActive] != 0 && precoveiculo/2 <= GetPlayerEuros(playerid))
{
PlayerActionMessage(playerid,15.0,"entrega um cheque ao gerente do Stand, e recebe um veiculo.");
SendClientMessage(playerid, COLOR_GREY, "================================================= ================================================== =====");
SendClientMessage(playerid, COLOR_WHITE, "Compraste o veiculo com sucesso. Este aparecerб na marinha de Palomino Creek em 10 horas ingame");
SendClientMessage(playerid, COLOR_GREY, "================================================= ================================================== =====");
SetTimerEx("buyvehtime", 20000, false, "ii", playerid, "TCarModel");
if(PlayerInfo[playerid][pVipActive] != 0)
{
GivePlayerEuros(playerid, -precoveiculo/2);
Businesses[i][Products]=Businesses[i][Products]-(precoveiculo/2/100);
Businesses[i][Till]+=precoveiculo;
OnPlayerDataSave(playerid);
}
else
{
GivePlayerEuros(playerid, -precoveiculo);
Businesses[i][Products]=Businesses[i][Products]-(precoveiculo/100);
Businesses[i][Till]+=precoveiculo;
}
if(PlayerInfo[playerid][pChave1] == 255)
{
PlayerInfo[playerid][pChave1] = c+1;
return 1;
}
else if(PlayerInfo[playerid][pChave2] == 255)
{
PlayerInfo[playerid][pChave2] = c+1;
return 1;
}
else if(PlayerInfo[playerid][pChave3] == 255)
{
PlayerInfo[playerid][pChave3] = c+1;
return 1;
}
else if(PlayerInfo[playerid][pChave4] == 255)
{
PlayerInfo[playerid][pChave4] = c+1;
return 1;
}
else if(PlayerInfo[playerid][pChave5] == 255)
{
PlayerInfo[playerid][pChave5] = c+1;
return 1;
}
else if(PlayerInfo[playerid][pChave6] == 255)
{
PlayerInfo[playerid][pChave6] = c+1;
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "*{FF0000} Erro:{FFFFFF} Nгo tens dinheiro suficiente!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "*{FF0000} Erro:{FFFFFF} Modelo Invбlido.");
return 1;
}
}
}
}
}
}
return 1;
}
}
}
}
}
else
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "*{FF0000} Erro:{FFFFFF} Jб tens seis carros nгo podes ter mais!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "*{FF0000} Erro:{FFFFFF} Nгo estбs no stand!");
return 1;
}
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)