23.09.2009, 18:52
Ok guys, need a bit of help here. Basicallly i've got a /getcar command.
Here's the code:
OnGameModeInit
Somewhere
The /getcar [Model/ID] Command
Ok, basically, I want the vehicles listed in the DisabledCars array to be disabled (have their variable set to CarInfo[ID][allow] = false
The rest of the vehicle ID's should have their variable set to CarInfo[ID][allow] = true;
But when I try spawning some of the vehicles, it says that the vehicle is disabled:
Some of them are disabled, some are not, though not correctly. Please could someone help me out. Maybe i've made a simple mistake i cannot see.
Any help wouldbe appreciated. Thanks.
(excuse the indentation, it's fine in the gamemode.)
Here's the code:
OnGameModeInit
pawn Код:
new DisabledCars[] = {407, 416, 425, 427, 432, 441, 447, 449, 464, 465, 476, 479, 501, 520, 537, 538, 552, 564, 569, 570, 577, 590, 591, 592, 594, 601, 606, 608, 610};
LoadDefaultDisabledVehicles();
pawn Код:
LoadDefaultDisabledVehicles()
{
for(new i = 400; i < MAX_SPAWNABLE_VEHICLES+400; i++)
{
CarInfo[i-400][allow] = true;
}
for (new x = 0; x < sizeof(DisabledCars); x++)
{
CarInfo[x][allow] = false;
}
printf("Disabled Vehicles Loaded!");
}
pawn Код:
zcmd(getcar, playerid, params[])
{
if (isnull(params))
{
SendClientMessage(playerid,AAD_COLOR_GREY,"USAGE: /getcar [Vehicle Name / Model ID]");
return 1;
}
new tmp[256],idx;
tmp = strtok(params, idx);
//if(Player[playerid][pPlaying] && (TeamStatus[gTeam[playerid]] != ATTACKING || VehiclesSpawned[gTeam[playerid]] >= (CurrentPlayers[gTeam[playerid]] * VPPPT) || ModeType == ARENA || ModeType == TDM || IsPlayerInAnyVehicle(playerid) || Vehicles > 200 || GetPlayerWeapon(playerid) == 46))return SendClientMessage(playerid,MainColors[2],"No.");
//if(Player[playerid][pPlaying] && Interior[Current][BASE] != 0)return SendClientMessage(playerid,AAD_COLOR_GREY,"This command is disabled for bases that use interiors");
if(!Player[playerid][pPlaying])
{
new car,vw,inter,iString[128],Float:XYZ[4];
idx = GetVehicleModelIDFromName(params);
if(idx != -1 && CarInfo[idx-400][allow] == false)return SendClientMessage(playerid,AAD_COLOR_GREY,"ERROR: This vehicle is disabled. NP");
if(idx == -1)
{
idx = strval(params);
if(idx < 400 || idx > 611)return SendClientMessage(playerid, AAD_COLOR_GREY, "ERROR: Invalid model or name. 400 || idx > 611 NP");
if(CarInfo[idx-400][allow] == false)return SendClientMessage(playerid,AAD_COLOR_GREY,"ERROR: This vehicle is disabled. NP");
}
GetPlayerPos(playerid,XYZ[0],XYZ[1],XYZ[2]);
GetPlayerFacingAngle(playerid,XYZ[3]);
vw = GetPlayerVirtualWorld(playerid);
inter = GetPlayerInterior(playerid);
if(IsVehicleTrailer(idx))car = CreateVehicle(idx,XYZ[0]-5,XYZ[1]-5,XYZ[2],XYZ[3],0,0,cellmax);
else car = CreateVehicle(idx,XYZ[0],XYZ[1],XYZ[2],XYZ[3],vColor[0][playerid],vColor[1][playerid],cellmax);
SetVehicleHealth(car,1000);
Vehicles++;
LinkVehicleToInterior(car,inter);
SetVehicleVirtualWorld(car,vw);
if(!IsVehicleTrailer(idx))PutPlayerInVehicle(playerid,car,0);
RoundVehicle[car] = false;
Destroy[car] = true;
format(iString,128,"*** Vehicle spawned: %s(%d) HP: 1000",CarList[idx-400],idx);
SendClientMessage(playerid,AAD_COLOR_GREY,iString);
if(IsNosCompatible(idx) == 1)
{
AddVehicleComponent(car,1010);
AddVehicleComponent(car,RandWheels[random(17)]);
}
return 1;
}
new Float:x,Float:y,Float:z,Float:r;
GetPlayerPos(playerid,x,y,z);
if(GetPointDistanceToPointEx(x,y,z,ds[dp][sx],ds[dp][sy],ds[dp][sz]) > 125.0)return SendClientMessage(playerid,AAD_COLOR_GREY," You are too far away from spawn (125+ units)");
if(!strlen(params))return SendClientMessage(playerid, AAD_COLOR_GREY,"USAGE: /car [Model/Name]");
new car,vw,inter,iString[128];
idx = GetVehicleModelIDFromName(params);
if(idx != -1 && CarInfo[idx-400][allow] == false)return SendClientMessage(playerid,AAD_COLOR_GREY,"ERROR: This vehicle is disabled.");
if(idx == -1)
{
idx = strval(params);
if(idx < 400 || idx > 611)return SendClientMessage(playerid, AAD_COLOR_GREY, "ERROR: Invalid model or name.");
if(CarInfo[idx-400][allow] == false)return SendClientMessage(playerid,AAD_COLOR_GREY,"ERROR: This vehicle is disabled.");
}
GetPlayerFacingAngle(playerid,r);
vw = GetPlayerVirtualWorld(playerid);
inter = GetPlayerInterior(playerid);
car = CreateVehicle(idx,x,y,z,r,vColor[0][playerid],vColor[1][playerid],cellmax);
SetVehicleHealth(car,1000);
VehiclesSpawned[Player[playerid][pTeam]]++;
Vehicles++;
LinkVehicleToInterior(car,inter);
SetVehicleVirtualWorld(car,vw);
if(!IsVehicleTrailer(idx))PutPlayerInVehicle(playerid,car,0);
RoundVehicle[car] = true;
Destroy[car] = true;
format(iString,128,"*** Vehicle spawned: %s(%d) HP: 1000",CarList[idx-400],idx);
SendClientMessage(playerid,AAD_COLOR_GREY,iString);
if(IsNosCompatible(idx) == 1)
{
AddVehicleComponent(car,1010);
AddVehicleComponent(car,1087);
AddVehicleComponent(car,RandWheels[random(17)]);
}
return 1;
}
Ok, basically, I want the vehicles listed in the DisabledCars array to be disabled (have their variable set to CarInfo[ID][allow] = false
The rest of the vehicle ID's should have their variable set to CarInfo[ID][allow] = true;
But when I try spawning some of the vehicles, it says that the vehicle is disabled:
pawn Код:
SendClientMessage(playerid,AAD_COLOR_GREY,"ERROR: This vehicle is disabled. NP");
Any help wouldbe appreciated. Thanks.
(excuse the indentation, it's fine in the gamemode.)