Get car command not working -
acade - 21.02.2010
Hello, the command below isn't spawning the players car.
Код:
command(getcar, playerid, params[])
{
#pragma unused params
if(DrugsHolding[playerid] > 0 || UncollectedCar[playerid] == 1 || HasFishingMarker[playerid] > 0 || DropCarRun[playerid] > 0)
{
SendClientMessage(playerid, COLOR_WHITE, "You must drop your drugs/fish/car pickup/car scrap off first.");
return 1;
}
DespawnOwnedCar(playerid);
GenerateOwnedCar(playerid);
UncollectedCar[playerid] = 1;
SendClientMessage(playerid, COLOR_WHITE, "The car has been re-spawned (at the last known position).");
SetPlayerCheckpoint(playerid, pStats[playerid][pCarX], pStats[playerid][pCarY], pStats[playerid][pCarZ], 10.0);
return 1;
}
Does anyone have an idea?
Re: Get car command not working -
Correlli - 21.02.2010
Post the DespawnOwnedCar & GenerateOwnedCar functions.
Re: Get car command not working -
acade - 21.02.2010
Код:
public GenerateOwnedCar(playerid)
{
new sum = 200;
sum += random(200);
if(DynamicCars[sum][CarType] == 3)
{
new car = sum - 1;
PlayerCarID[playerid] = sum;
DestroyVehicle(sum);
CreateVehicle(pStats[playerid][pCarModel], pStats[playerid][pCarX], pStats[playerid][pCarY], pStats[playerid][pCarZ], DynamicCars[car][CarAngle],pStats[playerid][pCarColor1],pStats[playerid][pCarColor2], -1);
DynamicCars[sum][CarType] = 4;
printf("[DEBUG] Vehicle %d (owned by %s) has been spawned.", sum, GetPlayerNameEx(playerid));
ChangeVehicleColor(PlayerCarID[playerid], pStats[playerid][pCarColor1], pStats[playerid][pCarColor2]);
}
else
{
sum = 200;
sum += random(200);
if(DynamicCars[sum][CarType] == 3)
{
new car = sum - 1;
PlayerCarID[playerid] = sum;
DestroyVehicle(sum);
CreateVehicle(pStats[playerid][pCarModel], pStats[playerid][pCarX], pStats[playerid][pCarY], pStats[playerid][pCarZ], DynamicCars[car][CarAngle],pStats[playerid][pCarColor1],pStats[playerid][pCarColor2], -1);
DynamicCars[sum][CarType] = 4;
printf("[DEBUG] Vehicle %d (owned by %s) has been spawned.", sum, GetPlayerNameEx(playerid));
ChangeVehicleColor(PlayerCarID[playerid], pStats[playerid][pCarColor1], pStats[playerid][pCarColor2]);
}
}
if(pStats[playerid][pCarNos] != 0)
{
new carmodel = GetVehicleModel(PlayerCarID[playerid]);
for (new i=0; i<sizeof(UnmodifiableVehicles); i++)
{
if (carmodel != UnmodifiableVehicles[i])
{
AddVehicleComponent(PlayerCarID[playerid], 1010);
}
}
}
}
Код:
public DespawnOwnedCar(playerid)
{
DynamicCars[PlayerCarID[playerid]][CarType] = 3;
GetVehiclePos(PlayerCarID[playerid], pStats[playerid][pCarX], pStats[playerid][pCarY], pStats[playerid][pCarZ]);
new car = PlayerCarID[playerid] - 1;
printf("[DEBUG] Vehicle %d (owned by %s) has/is being de-spawned.", PlayerCarID[playerid], GetPlayerNameEx(playerid));
DestroyVehicle(PlayerCarID[playerid]);
CreateVehicle(572, 2554.1904, -2536.1890, 12.8843, DynamicCars[car][CarAngle], 4, 4, -1);
PlayerCarID[playerid] = 0;
}
Re: Get car command not working -
Rizard - 21.02.2010
both functions do not return a value... or can I learn something new here?
Riz
Re: Get car command not working -
Correlli - 21.02.2010
Debug your functions and you'll know where the exact problem is.
Re: Get car command not working -
acade - 22.02.2010
Sorry about being so n00by on this question,
How do I go about debuging a function?
Re: Get car command not working -
Correlli - 22.02.2010
Use the print/printf/SendClientMessage function to send the message and to see where the problem is.
Re: Get car command not working -
adsy - 22.02.2010
you need a return 1; or a return 0; at the end of every function
Re: Get car command not working -
acade - 22.02.2010
Код:
public DespawnOwnedCar(playerid)
{
DynamicCars[PlayerCarID[playerid]][CarType] = 3;
GetVehiclePos(PlayerCarID[playerid], pStats[playerid][pCarX], pStats[playerid][pCarY], pStats[playerid][pCarZ]);
new car = PlayerCarID[playerid] - 1;
printf("[DEBUG] Vehice Pos Saved");
printf("[DEBUG] Vehicle %d (owned by %s) has/is being de-spawned.", PlayerCarID[playerid], GetPlayerNameEx(playerid));
DestroyVehicle(PlayerCarID[playerid]);
printf("[DEBUG] Vehice Destroyed");
CreateVehicle(572, 2554.1904, -2536.1890, 12.8843, DynamicCars[car][CarAngle], 4, 4, -1);
printf("[DEBUG] Vehice Created");
PlayerCarID[playerid] = 0;
return 0;
}
Код:
public GenerateOwnedCar(playerid)
{
new sum = 200;
sum += random(200);
if(DynamicCars[sum][CarType] == 3)
{
new car = sum - 1;
PlayerCarID[playerid] = sum;
DestroyVehicle(sum);
printf("[DEBUG] Vehicle %d (owned by %s) has been destroyed.", sum, GetPlayerNameEx(playerid));
CreateVehicle(pStats[playerid][pCarModel], pStats[playerid][pCarX], pStats[playerid][pCarY], pStats[playerid][pCarZ], DynamicCars[car][CarAngle],pStats[playerid][pCarColor1],pStats[playerid][pCarColor2], -1);
printf("[DEBUG] Vehicle %d (owned by %s) has been created", sum, GetPlayerNameEx(playerid));
DynamicCars[sum][CarType] = 4;
printf("[DEBUG] Vehicle %d (owned by %s) car type set to 4t", sum, GetPlayerNameEx(playerid));
printf("[DEBUG] Vehicle %d (owned by %s) has been spawned.", sum, GetPlayerNameEx(playerid));
ChangeVehicleColor(PlayerCarID[playerid], pStats[playerid][pCarColor1], pStats[playerid][pCarColor2]);
}
else
{
sum = 200;
sum += random(200);
if(DynamicCars[sum][CarType] == 3)
{
new car = sum - 1;
PlayerCarID[playerid] = sum;
DestroyVehicle(sum);
printf("[DEBUG] Vehicle %d (owned by %s) has been destroyed.", sum, GetPlayerNameEx(playerid));
CreateVehicle(pStats[playerid][pCarModel], pStats[playerid][pCarX], pStats[playerid][pCarY], pStats[playerid][pCarZ], DynamicCars[car][CarAngle],pStats[playerid][pCarColor1],pStats[playerid][pCarColor2], -1);
printf("[DEBUG] Vehicle %d (owned by %s) has been created", sum, GetPlayerNameEx(playerid));
DynamicCars[sum][CarType] = 4;
printf("[DEBUG] Vehicle %d (owned by %s) car type set to 4", sum, GetPlayerNameEx(playerid));
printf("[DEBUG] Vehicle %d (owned by %s) has been spawned.", sum, GetPlayerNameEx(playerid));
ChangeVehicleColor(PlayerCarID[playerid], pStats[playerid][pCarColor1], pStats[playerid][pCarColor2]);
}
}
if(pStats[playerid][pCarNos] != 0)
{
new carmodel = GetVehicleModel(PlayerCarID[playerid]);
for (new i=0; i<sizeof(UnmodifiableVehicles); i++)
{
if (carmodel != UnmodifiableVehicles[i])
{
AddVehicleComponent(PlayerCarID[playerid], 1010);
}
}
}
return 0;
}
Got this from the log
Код:
[00:02:52] [DEBUG] Vehice Pos Saved
[00:02:52] [DEBUG] Vehicle 0 (owned by name here) has/is being de-spawned.
[00:02:52] [DEBUG] Vehice Destroyed
Re: Get car command not working -
acade - 23.02.2010
Could someone possibly help me?
Thanks