ManualVehicleEngineAndLights();
new MotorAuto[MAX_VEHICLES];
MotorAuto[vehicleid]=0;
{ if(MotorAuto[vehicleid] == 0)//si el motor esta apagado { SendClientMessage(playerid,C_Blanco,"VEHICULO: El motor se encuentra apagado");// te manda el mensaje si esta apagado } if(MotorAuto[vehicleid] == 1)//si el motor esta encendido { SendClientMessage(playerid,C_Blanco,"VEHICULO: El motor se encuentra encendido");//mensaje si el motor esta encendido } return 1; }
forward EncenderMotor(playerid); public EncenderMotor(playerid) { new IDAuto = GetPlayerVehicleID(playerid);//define que IDAuto es la id del auto new enginem, lights, alarm, doors, bonnet, boot, objective;//define las cosas del auto GetVehicleParamsEx(GetPlayerVehicleID(playerid),enginem, lights, alarm, doors, bonnet, boot, objective); SetVehicleParamsEx(GetPlayerVehicleID(playerid),VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective);//deja el auto con las luces encendidas, motor, etc. GameTextForPlayer(playerid, "~w~Motor ~g~Encendido",1000,3);//mensaje de encendido MotorAuto[IDAuto] = 1;//deja el motor encendido } forward ApagarMotor(playerid); public ApagarMotor(playerid) { new IDAuto = GetPlayerVehicleID(playerid); new enginem, lights, alarm, doors, bonnet, boot, objective; GetVehicleParamsEx(GetPlayerVehicleID(playerid),enginem, lights, alarm, doors, bonnet, boot, objective); SetVehicleParamsEx(GetPlayerVehicleID(playerid),VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);//deja el motor y las demas cosas apagadas GameTextForPlayer(playerid, "~w~Motor ~r~Apagado",1000,3);//mensaje de apagado MotorAuto[IDAuto] = 0;//deja el motor apagado }
"command(crearcoche, playerid, params[]) { new carid, string[128], Float: CarToX, Float: CarToY, Float: CarToZ, physical_car_id; if(sscanf(params, "d", carid)) { if(JugadorInfo[playerid][jAdmin] >= 1) { SendClientMessage(playerid, WHITE, "USO: /crearcoche [ID]"); } } else { if(JugadorInfo[playerid][jAdmin] >= 3) { if(CarCount < MAX_VEHICLES) { if(carid < 400 || carid > 611) { SendClientMessage(playerid, WHITE, "Las IDS son entre 400 y 611."); return 1; } GetPlayerPos(playerid, CarToX, CarToY, CarToZ); physical_car_id = CreateVehicle(carid, CarToX, CarToY+4, CarToZ, 90, -1, -1, -1); format(string, sizeof(string), "Has spawneado un auto id %d. Si quieres guardarlo usa: /guardarcoche.", carid); SendClientMessage(playerid, WHITE, string); AdminSpawned[SpawnedVehicles] = physical_car_id; SpawnedVehicles++; LinkVehicleToInterior(physical_car_id, GetPlayerInterior(playerid)); SetVehicleVirtualWorld(physical_car_id, GetPlayerVirtualWorld(playerid)); } else { SendClientMessage(playerid, WHITE, "Despawnea los actuales spawneados antes de crear otro."); } } } return 1; }
static bool:param[MAX_VEHICLES][7]; //Global
new vehicleid = GetPlayerVehicleID(playerid)
GetVehicleParamsEx(vehicleid,param[vehicleid][0], param[vehicleid][1], param[vehicleid][2], param[vehicleid][3], param[vehicleid][4], param[vehicleid][5], param[vehicleid][6]);
SetVehicleParamsEx(vehicleid,param[vehicleid][0]=true, param[vehicleid][1], param[vehicleid][2], param[vehicleid][3], param[vehicleid][4], param[vehicleid][5], param[vehicleid][6]);
ami me pasaba lo mismo , funcionaba todo bien y de pronto no las detectaba.
mi solucion fue la siguiente y funciono perfectamente . pawn Код:
|
new bool:MotorAuto[MAX_VEHICLES];
static bool:param[MAX_VEHICLES][7];
/*
param[vehicleid][0] = enginem
param[vehicleid][1] = lights
param[vehicleid][2] = alarm
param[vehicleid][3] = doors
param[vehicleid][4] = bonnet
param[vehicleid][5] = boot
param[vehicleid][6] = objective
*/
new MatarTimer[MAX_PLAYERS][2];
public OnGamemodeInit() {
ManualVehicleEngineAndLights();
return true;
}
public OnPlayerStateChange(playerid, newstate, oldstate) {
new vehicleid = GetPlayerVehicleID(playerid);
switch(GetPlayerState(playerid)) {
case PLAYER_STATE_DRIVER: {
switch(MotorAuto[vehicleid]) {
case false: {
SendClientMessage(playerid,-1,"VEHICULO: El motor se encuentra apagado");
}
case true: {
SendClientMessage(playerid,-1,"VEHICULO: El motor se encuentra encendido");
}
}
}
case PLAYER_STATE_ONFOOT, PLAYER_STATE_PASSENGER: {
KillTimer(MatarTimer[playerid][0]);
KillTimer(MatarTimer[playerid][1]);
}
}
return true;
}
public OnVehicleSpawn(vehicleid) {
param[vehicleid][0] = false;
GetVehicleParamsEx(vehicleid,param[vehicleid][0], param[vehicleid][1], param[vehicleid][2], param[vehicleid][3], param[vehicleid][4], param[vehicleid][5], param[vehicleid][6]);
SetVehicleParamsEx(vehicleid,param[vehicleid][0], param[vehicleid][1], param[vehicleid][2], param[vehicleid][3], param[vehicleid][4], param[vehicleid][5], param[vehicleid][6]);
MotorAuto[vehicleid] = false;
return true;
}
public OnVehicleDeath(vehicleid, killerid) {
param[vehicleid][0] = false;
GetVehicleParamsEx(vehicleid,param[vehicleid][0], param[vehicleid][1], param[vehicleid][2], param[vehicleid][3], param[vehicleid][4], param[vehicleid][5], param[vehicleid][6]);
SetVehicleParamsEx(vehicleid,param[vehicleid][0], param[vehicleid][1], param[vehicleid][2], param[vehicleid][3], param[vehicleid][4], param[vehicleid][5], param[vehicleid][6]);
MotorAuto[vehicleid] = false;
KillTimer(MatarTimer[killerid][0]);
KillTimer(MatarTimer[killerid][1]);
return true;
}
forward EncendidoDelMotor(playerid, vehicleid);
public EncendidoDelMotor(playerid, vehicleid) {
if(IsPlayerConnected(playerid) && IsPlayerInAnyVehicle(playerid)) {
param[vehicleid][0] = true;
GetVehicleParamsEx(vehicleid,param[vehicleid][0], param[vehicleid][1], param[vehicleid][2], param[vehicleid][3], param[vehicleid][4], param[vehicleid][5], param[vehicleid][6]);
SetVehicleParamsEx(vehicleid,param[vehicleid][0], param[vehicleid][1], param[vehicleid][2], param[vehicleid][3], param[vehicleid][4], param[vehicleid][5], param[vehicleid][6]);
MotorAuto[vehicleid] = true;
GameTextForPlayer(playerid, "~w~Motor ~g~Encendido",1000,3);
KillTimer(MatarTimer[playerid][0]);
}
return true;
}
forward ApagadoDelMotor(playerid, vehicleid);
public ApagadoDelMotor(playerid, vehicleid) {
if(IsPlayerConnected(playerid) && IsPlayerInAnyVehicle(playerid)) {
param[vehicleid][0] = false;
GetVehicleParamsEx(vehicleid,param[vehicleid][0], param[vehicleid][1], param[vehicleid][2], param[vehicleid][3], param[vehicleid][4], param[vehicleid][5], param[vehicleid][6]);
SetVehicleParamsEx(vehicleid,param[vehicleid][0], param[vehicleid][1], param[vehicleid][2], param[vehicleid][3], param[vehicleid][4], param[vehicleid][5], param[vehicleid][6]);
MotorAuto[vehicleid] = false;
GameTextForPlayer(playerid, "~w~Motor ~r~Apagado",1000,3);
KillTimer(MatarTimer[playerid][1]);
}
return true;
}
COMMAND:crearcoche(playerid, params[]) {
new Float:pos[3], string[128], vehiculoid;
if(JugadorInfo[playerid][jAdmin] >= 1) return SendClientMessage(playerid, -1, "No Eres administrador");
if(sscanf(params, "d", params[0])) return SendClientMessage(playerid, -1, "USO: /crearcoche [ID]");
if(params[0] < 400 || params[0] > 611) return SendClientMessage(playerid, -1, "Las IDS son entre 400 y 611.");
if(CarCount < MAX_VEHICLES) return SendClientMessage(playerid, -1, "Despawnea los actuales spawneados antes de crear otro.");
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
vehiculoid = CreateVehicle(params[0], pos[0], pos[1], pos[2], 90, -1, -1, -1);
format(string, sizeof(string), "Has spawneado un auto id %d. Si quieres guardarlo usa: /guardarcoche.", params[0]);
SendClientMessage(playerid, -1, string);
AdminSpawned[SpawnedVehicles] = vehiculoid;
SpawnedVehicles++;
LinkVehicleToInterior(vehiculoid, GetPlayerInterior(playerid));
SetVehicleVirtualWorld(vehiculoid, GetPlayerVirtualWorld(playerid));
return true;
}
/*
MatarTimer[playerid][0] = SetTimerEx("EncendidoDelMotor", 1000, true, "ii", playerid, vehicleid);
MatarTimer[playerid][1] = SetTimerEx("ApagadoDelMotor", 1000, true, "ii", playerid, vehicleid);
*/