/Spawncar is not functional -
nmader - 17.09.2012
Basically I have been working on a /spawncar command that will spawn a car for administrators upon a command. Each time I type /spawncar it will give the error message stating I have not filled in the other required fields, although I have.
Here is the script:
pawn Код:
command(spawncar, playerid, vehicleid, params[])
{
new carid, string[128], Float: CarToX, Float: CarToY, Float: CarToZ, physical_car_id, c1, c2;
if(sscanf(params, "ddd", carid, c1, c2))
{
if(Player[playerid][AdminLevel] >= 1)
{
SendClientMessage(playerid, ERROR, "SYNTAX: /spawncar [vehicleid] [colour 1] [colour 2]");
}
else
{
SendClientMessage(playerid, ERROR, "ERROR: You are not authorized to use this command!");
}
}
else
{
if(Player[playerid][AdminLevel] >= 1)
{
if(CarCount < MAX_VEHICLES)
{
if(carid < 400 || carid > 611)
{
SendClientMessage(playerid, ERROR, "ERROR: Valid car IDs start from 400, ending at 611.");
return 1;
}
GetPlayerPos(playerid, CarToX, CarToY, CarToZ);
physical_car_id = CreateVehicle(carid, CarToX, CarToY+4, CarToZ, 90, -1, -1, -1);
ChangeVehicleColor(carid, c1, c2);
SendClientMessage(playerid, WHITE, string);
AdminSpawned[SpawnedVehicles] = physical_car_id;
SpawnedVehicles++;
PutPlayerInVehicle(playerid, physical_car_id, 0);
LinkVehicleToInterior(physical_car_id, GetPlayerInterior(playerid));
SetVehicleVirtualWorld(physical_car_id, GetPlayerVirtualWorld(playerid));
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
}
else
{
SendClientMessage(playerid, WHITE, "Despawn the current spawned vehicles before spawning any more (or attempting to do so).");
}
}
}
return 1;
}
Re: /Spawncar is not functional -
antonio112 - 17.09.2012
pawn Код:
command(spawncar, playerid, vehicleid, params[])
{
new carid, string[128], Float: CarToX, Float: CarToY, Float: CarToZ, physical_car_id, c1, c2;
if(Player[playerid][AdminLevel] < 1)
return SendClientMessage(playerid, ERROR, "ERROR: You are not authorized to use this command!");
if(sscanf(params, "ddd", carid, c1, c2))
return SendClientMessage(playerid, ERROR, "SYNTAX: /spawncar [vehicleid] [colour 1] [colour 2]");
if(CarCount >= MAX_VEHICLES)
return SendClientMessage(playerid, WHITE, "Despawn the current spawned vehicles before spawning any more (or attempting to do so).");
if(carid < 400 || carid > 611)
return SendClientMessage(playerid, ERROR, "ERROR: Valid car IDs start from 400, ending at 611.");
GetPlayerPos(playerid, CarToX, CarToY, CarToZ);
physical_car_id = CreateVehicle(carid, CarToX, CarToY+4, CarToZ, 90, -1, -1, -1);
ChangeVehicleColor(carid, c1, c2);
SendClientMessage(playerid, WHITE, string);
AdminSpawned[SpawnedVehicles] = physical_car_id;
SpawnedVehicles++;
PutPlayerInVehicle(playerid, physical_car_id, 0);
LinkVehicleToInterior(physical_car_id, GetPlayerInterior(playerid));
SetVehicleVirtualWorld(physical_car_id, GetPlayerVirtualWorld(playerid));
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
return 1;
}
Re: /Spawncar is not functional -
nmader - 17.09.2012
May I ask what was changed so I can avoid this problem in the future?
Re: /Spawncar is not functional -
antonio112 - 17.09.2012
Well, to be honest, I don't know what you did wrong. This is the way I work and it probably should work. Check yourself out what I did and see what you did wrong.
I found it's easier to work this way. First check if the stats / variables / etc are false and return the command and then do the command part.
I find it much more easier this way.
ps: Does the command work ?
Re: /Spawncar is not functional -
nmader - 17.09.2012
I am going to test it now.
Re: /Spawncar is not functional -
antonio112 - 17.09.2012
Ok. Let me know how it ended up. I can't guarantee the command I made works... I'll make it work if it doesn't, don't worry.
Re: /Spawncar is not functional -
nmader - 17.09.2012
No, it did not work...
Re: /Spawncar is not functional -
antonio112 - 17.09.2012
You get any error or ?
Re: /Spawncar is not functional -
nmader - 17.09.2012
Nope, it is the same problem as before, it keeps saying "SYNTAX: /spawncar [Vehicle ID] [Color 1] [Color 2]".
Re: /Spawncar is not functional -
antonio112 - 17.09.2012
Ops, sorry. Here's the working version:
pawn Код:
command(spawncar, playerid, vehicleid, params[])
{
new carid, string[128], Float: CarToX, Float: CarToY, Float: CarToZ, physical_car_id, c1, c2;
if(Player[playerid][AdminLevel] < 1)
return SendClientMessage(playerid, ERROR, "ERROR: You are not authorized to use this command!");
if(sscanf(params, "ddd", carid, c1, c2))
return SendClientMessage(playerid, ERROR, "SYNTAX: /spawncar [vehicleid] [colour 1] [colour 2]");
if(CarCount >= MAX_VEHICLES)
return SendClientMessage(playerid, WHITE, "Despawn the current spawned vehicles before spawning any more (or attempting to do so).");
if(carid < 400 || carid > 611)
return SendClientMessage(playerid, ERROR, "ERROR: Valid car IDs start from 400, ending at 611.");
GetPlayerPos(playerid, CarToX, CarToY, CarToZ);
physical_car_id = CreateVehicle(carid, CarToX, CarToY+4, CarToZ, 90, -1, -1, -1);
ChangeVehicleColor(carid, c1, c2);
SendClientMessage(playerid, WHITE, string);
AdminSpawned[SpawnedVehicles] = physical_car_id;
SpawnedVehicles++;
PutPlayerInVehicle(playerid, physical_car_id, 0);
LinkVehicleToInterior(physical_car_id, GetPlayerInterior(playerid));
SetVehicleVirtualWorld(physical_car_id, GetPlayerVirtualWorld(playerid));
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
return 1;
}
LE: Wait, that won't work either, let me see what's wrong with sscanf plugin. I think I did something wrong, I get "sscanf error: System not initialised." error in log.
LE2: Alright, tested the command myself and it works for me perfectly. Try to update your sscanf2 to last version from
here.