if(strcmp(cmd, "/cargar", true) == 0) //Cargar
{
new opcion[25];
opcion = strtok(cmdtext, idx);
if(!strlen(opcion))
{
SendClientMessage(playerid, Naranja, "* /Cargar [Opciуn]");
SendClientMessage(playerid, Naranja, "Opciones: Camion,Avion");
return 1;
}
if(strcmp(opcion,"camion",true) == 0)
{
if(PlayerInfo[playerid][pTrabajo] != 1) return SendClientMessage(playerid,Rojo,"* No eres camionero");
{
if(Cargado[playerid] == 1) return SendClientMessage(playerid, Rojo, "* Debes entregar el otro camiуn antes de hacer otro viaje.");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, Rojo, "* Ese camion ya estб en uso.");
new vehicleid = GetPlayerVehicleID(playerid);
if(IsCamion(vehicleid))
{
if(Chofer[GetPlayerVehicleID(playerid)] == INVALID_PLAYER_ID)
{
SendClientMessage(playerid, Blanco, "Dirijete al punto rojo marcado en el mapa para poder cargar el camiуn.");
SetPlayerCheckpoint(playerid,-116.3876,-322.6960,1.4928,7.0);
}
else SendClientMessage(playerid, Rojo, "* Ese camion ya estб en uso.");
}
else SendClientMessage(playerid, Rojo, "* Necesitas estar en un camiуn.");
}
}
return 1;
}
for(new i=0;i<MAX_VEHICLES;i++)
{
if(Chofer[i] == playerid)
{
Chofer[i] = INVALID_PLAYER_ID;
CamionCargado[i] = 0;
}
}
for(new i=0;i<MAX_VEHICLES;i++)
{
if(CamionCargado[CamionID[playerid]] == 1)
{
//Respawnear(CamionID[playerid]);
CamionCargado[CamionID[playerid]] = 0;
Chofer[CamionID[playerid]] = INVALID_PLAYER_ID;
}
}
|
Y al momento de spawnear el camiуn tu lo seteas a INVALID_PLAYER_ID?
|
|
Solo puse un camiуn de prueba y esta como los demбs vehнculos de trabajos, asн:
AddStaticVehicleEx(456,1745.6877,-2072.1392,13.5060,358.5654,6,0,600); //Camiуn |
#define MAX_CAMIONES 25
enum infocamiones
{
ID,
bool:Cargado,
Chofer
};
new InfoCamion[MAX_CAMIONES][infocamiones],ultimocamion;
public OnGameModeInit()
{
CrearCamion(456,1745.6877,-2072.1392,13.5060,358.5654,6,0,600);
return 1;
}
stock CrearCamion(model,Float:x,Float:y,Float:z,Float:r,c1,c2,respawntime)
{
InfoCamion[ultimocamion][ID] = AddStaticVehicleEx(model,x,y,z,r,c1,c2,respawntime);
InfoCamion[ultimocamion][Cargado] = false;
InfoCamion[ultimocamion][Chofer] = -1;
ultimocamion++;
}
stock EsUnCamion(vehicleid)
{
for(new i = 0; i < MAX_CAMIONES; i++)
{
if(InfoCamion[i][ID] == vehicleid)
{
return true;
break;
}
}
return false;
}
|
Deberнas darles una ID respectiva a los camiones, hiciste tremendo embole con lo que hiciste.
Te podes guiar con lo siguiente: PHP код:
|
function TrabajoCamionero(playerid, Tipo)
{
if(Tipo == EntregarArmero)
{
SendClientMessage(playerid,-1,"Entrega el camiуn en condiciones para poder recibir el pago.");
TogglePlayerControllable(playerid,1);
Cargamento[playerid] =1;
SetPlayerCheckpoint(playerid,-116.3876,-322.6960,1.4928,7.0);
Cargado[playerid]=2;
}
else if(Tipo == Entregar247)
{
SendClientMessage(playerid,-1,"Entrega el camiуn en condiciones para poder recibir el pago.");
TogglePlayerControllable(playerid,1);
Cargamento[playerid]=4;
SetPlayerCheckpoint(playerid,-116.3876,-322.6960,1.4928,7.0);
Cargado[playerid]=2;
}
else if(Tipo == EntregarDroga)
{
SendClientMessage(playerid,-1,"Entrega el camiуn en condiciones para poder recibir el pago.");
TogglePlayerControllable(playerid,1);
Cargamento[playerid]=3;
SetPlayerCheckpoint(playerid,-116.3876,-322.6960,1.4928,7.0);
Cargado[playerid]=2;
}
else if(Tipo == EntregarRopa)
{
SendClientMessage(playerid,-1,"Entrega el camiуn en condiciones para poder recibir el pago.");
TogglePlayerControllable(playerid,1);
Cargamento[playerid]=2;
SetPlayerCheckpoint(playerid,-116.3876,-322.6960,1.4928,7.0);
Cargado[playerid]=2;
}
else if(Tipo == CargarArmas)
{
SendClientMessage(playerid,-1,"Tu camiуn fuй cargado correctamente, lleva el camiуn al punto rojo marcado en el mapa.");
Cargamento[playerid]=1;
TogglePlayerControllable(playerid,1);
SetPlayerCheckpoint(playerid, 2461.9583,-2617.2573,13.5539,7.0);
}
else if(Tipo == CargarRopa)
{
SendClientMessage(playerid,-1,"Tu camiуn fuй cargado correctamente, lleva el camiуn al punto rojo marcado en el mapa.");
Cargamento[playerid]=2;
TogglePlayerControllable(playerid,1);
SetPlayerCheckpoint(playerid,2234.5420,-1689.8008,13.8677 ,7.0);
}
else if(Tipo == CargarDrogas)
{
SendClientMessage(playerid,-1,"Tu camiуn fuй cargado correctamente, lleva el camiуn al punto rojo marcado en el mapa.");
Cargamento[playerid]=3;
TogglePlayerControllable(playerid,1);
SetPlayerCheckpoint(playerid,2362.1731,-1180.6930,27.5124,7.0);
}
else if(Tipo == Cargar247)
{
SendClientMessage(playerid,-1,"Tu camiуn fuй cargado correctamente, lleva el camiуn al punto rojo marcado en el mapa.");
Cargamento[playerid]=4;
TogglePlayerControllable(playerid,1);
SetPlayerCheckpoint(playerid, 1838.1060,-1831.8807,13.4781,7.0);
}
return 1;
}
|
Al poner todo asн me tira un error en una funciуn cuando cargas el camiуn
Код:
function TrabajoCamionero(playerid, Tipo)
{
if(Tipo == EntregarArmero)
{
SendClientMessage(playerid,-1,"Entrega el camiуn en condiciones para poder recibir el pago.");
TogglePlayerControllable(playerid,1);
Cargamento[playerid] =1;
SetPlayerCheckpoint(playerid,-116.3876,-322.6960,1.4928,7.0);
Cargado[playerid]=2;
}
else if(Tipo == Entregar247)
{
SendClientMessage(playerid,-1,"Entrega el camiуn en condiciones para poder recibir el pago.");
TogglePlayerControllable(playerid,1);
Cargamento[playerid]=4;
SetPlayerCheckpoint(playerid,-116.3876,-322.6960,1.4928,7.0);
Cargado[playerid]=2;
}
else if(Tipo == EntregarDroga)
{
SendClientMessage(playerid,-1,"Entrega el camiуn en condiciones para poder recibir el pago.");
TogglePlayerControllable(playerid,1);
Cargamento[playerid]=3;
SetPlayerCheckpoint(playerid,-116.3876,-322.6960,1.4928,7.0);
Cargado[playerid]=2;
}
else if(Tipo == EntregarRopa)
{
SendClientMessage(playerid,-1,"Entrega el camiуn en condiciones para poder recibir el pago.");
TogglePlayerControllable(playerid,1);
Cargamento[playerid]=2;
SetPlayerCheckpoint(playerid,-116.3876,-322.6960,1.4928,7.0);
Cargado[playerid]=2;
}
else if(Tipo == CargarArmas)
{
SendClientMessage(playerid,-1,"Tu camiуn fuй cargado correctamente, lleva el camiуn al punto rojo marcado en el mapa.");
Cargamento[playerid]=1;
TogglePlayerControllable(playerid,1);
SetPlayerCheckpoint(playerid, 2461.9583,-2617.2573,13.5539,7.0);
}
else if(Tipo == CargarRopa)
{
SendClientMessage(playerid,-1,"Tu camiуn fuй cargado correctamente, lleva el camiуn al punto rojo marcado en el mapa.");
Cargamento[playerid]=2;
TogglePlayerControllable(playerid,1);
SetPlayerCheckpoint(playerid,2234.5420,-1689.8008,13.8677 ,7.0);
}
else if(Tipo == CargarDrogas)
{
SendClientMessage(playerid,-1,"Tu camiуn fuй cargado correctamente, lleva el camiуn al punto rojo marcado en el mapa.");
Cargamento[playerid]=3;
TogglePlayerControllable(playerid,1);
SetPlayerCheckpoint(playerid,2362.1731,-1180.6930,27.5124,7.0);
}
else if(Tipo == Cargar247)
{
SendClientMessage(playerid,-1,"Tu camiуn fuй cargado correctamente, lleva el camiуn al punto rojo marcado en el mapa.");
Cargamento[playerid]=4;
TogglePlayerControllable(playerid,1);
SetPlayerCheckpoint(playerid, 1838.1060,-1831.8807,13.4781,7.0);
}
return 1;
}
error 028: invalid subscript (not an array or too many subscripts): "Cargado" warning 215: expression has no effect error 001: expected token: ";", but found "]" error 029: invalid expression, assumed zero fatal error 107: too many error messages on one line |