Need help with car spawner -
1fret - 06.08.2014
i mad a car spawner command and its 100% working,but i have 1 small problem why when i spawn a car and the car got damage(caught fire and blow up)it respawns at the place/position you spawned it.Im wondering if there is a way to stop that from happening
Re: Need help with car spawner -
Don_Cage - 06.08.2014
Show your code
Re: Need help with car spawner -
1fret - 06.08.2014
pawn Код:
COMMAND:car(playerid,params[])
{
if(AdminLevel[playerid] >= 3)
{
new car;
if(IsPlayerInAnyVehicle(playerid)) return 1;
if(sscanf(params, "i", car)) return SendClientMessage(playerid, COLOR_RED, "USE: /car [car id]");
if(strval(params) >611 || strval(params) <400) return SendClientMessage(playerid, COLOR_RED, "That id doesn't exist[400-611]");
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x,y,z);
GetPlayerFacingAngle(playerid, a);
car = CreateVehicle(strval(params), x, y, z,a, -1, -1, 60);
PutPlayerInVehicle(playerid, car, 0);
}
else SendClientMessage(playerid,COLOR_RED,"You need to be an level 3 admin to use this command");
return 1;
}
Re: Need help with car spawner -
DavidBilla - 06.08.2014
car = CreateVehicle(strval(params), x, y, z,a, -1, -1, -1);
This will prevent the car from respawning. Just replaced the 60 seconds time delay to -1.
Hope it solves your problem.
Re: Need help with car spawner -
1fret - 06.08.2014
Quote:
Originally Posted by DavidBilla
car = CreateVehicle(strval(params), x, y, z,a, -1, -1, -1);
This will prevent the car from respawning. Just replaced the 60 seconds time delay to -1.
Hope it solves your problem.
|
doesnt work any other suggestion
Respuesta: Need help with car spawner -
ThePhenix - 06.08.2014
You can test this, it surely will work:
PHP код:
new CarToDestroy[MAX_VEHICLES];
COMMAND:car(playerid,params[])
{
if(AdminLevel[playerid] >= 3)
{
new car;
if(IsPlayerInAnyVehicle(playerid)) return 1;
if(sscanf(params, "i", car)) return SendClientMessage(playerid, COLOR_RED, "USE: /car [car id]");
if(strval(params) >611 || strval(params) <400) return SendClientMessage(playerid, COLOR_RED, "That id doesn't exist[400-611]");
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x,y,z);
GetPlayerFacingAngle(playerid, a);
CarToDestroy[car] = CreateVehicle(strval(params), x, y, z,a, -1, -1, 60);
PutPlayerInVehicle(playerid, CarToDestroy[car], 0);
}
else SendClientMessage(playerid,COLOR_RED,"You need to be an level 3 admin to use this command");
return 1;
}
public OnVehicleSpawn(vehicleid)
{
for(new i; i < MAX_VEHICLES; i++)
{
if(vehicleid == CarToDestroy[i])
{
DestroyVehicle(vehicleid);
break;
}
}
return 1;
}
Re: Respuesta: Need help with car spawner -
1fret - 06.08.2014
Quote:
Originally Posted by ThePhenix
You can test this, it surely will work:
PHP код:
new CarToDestroy[MAX_VEHICLES];
COMMAND:car(playerid,params[])
{
if(AdminLevel[playerid] >= 3)
{
new car;
if(IsPlayerInAnyVehicle(playerid)) return 1;
if(sscanf(params, "i", car)) return SendClientMessage(playerid, COLOR_RED, "USE: /car [car id]");
if(strval(params) >611 || strval(params) <400) return SendClientMessage(playerid, COLOR_RED, "That id doesn't exist[400-611]");
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x,y,z);
GetPlayerFacingAngle(playerid, a);
CarToDestroy[car] = CreateVehicle(strval(params), x, y, z,a, -1, -1, 60);
PutPlayerInVehicle(playerid, CarToDestroy[car], 0);
}
else SendClientMessage(playerid,COLOR_RED,"You need to be an level 3 admin to use this command");
return 1;
}
public OnVehicleSpawn(vehicleid)
{
for(new i; i < MAX_VEHICLES; i++)
{
if(vehicleid == CarToDestroy[i])
{
DestroyVehicle(vehicleid);
break;
}
}
return 1;
}
|
Thanks man
Re: Need help with car spawner -
Threshold - 06.08.2014
This would be a better alternative:
pawn Код:
new pVeh[MAX_PLAYERS]; //At the top of your script.
COMMAND:car(playerid,params[])
{
if(AdminLevel[playerid] < 3) return SendClientMessage(playerid, COLOR_RED, "You need to be a level 3 admin to use this command");
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must not be in a vehicle to use this command");
new car;
if(sscanf(params, "i", car)) return SendClientMessage(playerid, COLOR_RED, "USE: /car [car id]");
if(!(400 <= car <= 611)) return SendClientMessage(playerid, COLOR_RED, "That id doesn't exist [400-611]");
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x,y,z);
GetPlayerFacingAngle(playerid, a);
if(pVeh[playerid]) DestroyVehicle(pVeh[playerid]);
PutPlayerInVehicle(playerid, (pVeh[playerid] = CreateVehicle(car, x, y, z, a, -1, -1, -1)), 0);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(pVeh[playerid])
{
DestroyVehicle(pVeh[playerid]);
pVeh[playerid] = 0;
}
return 1;
}
public OnVehicleSpawn(vehicleid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(vehicleid != pVeh[i]) continue;
DestroyVehicle(pVeh[i]);
pVeh[i] = 0;
break;
}
return 1;
}
EDIT: ThePhenix's code will not work. It might work visually, but eventually you will realise that it's not working completely functionally.
Respuesta: Re: Need help with car spawner -
ThePhenix - 06.08.2014
Quote:
Originally Posted by Threshold
This would be a better alternative:
pawn Код:
new pVeh[MAX_PLAYERS]; //At the top of your script.
COMMAND:car(playerid,params[]) { if(AdminLevel[playerid] < 3) return SendClientMessage(playerid, COLOR_RED, "You need to be a level 3 admin to use this command"); if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must not be in a vehicle to use this command"); new car; if(sscanf(params, "i", car)) return SendClientMessage(playerid, COLOR_RED, "USE: /car [car id]"); if(!(400 <= car <= 611)) return SendClientMessage(playerid, COLOR_RED, "That id doesn't exist [400-611]"); new Float:x, Float:y, Float:z, Float:a; GetPlayerPos(playerid, x,y,z); GetPlayerFacingAngle(playerid, a); if(pVeh[playerid]) DestroyVehicle(pVeh[playerid]); PutPlayerInVehicle(playerid, (pVeh[playerid] = CreateVehicle(car, x, y, z, a, -1, -1, -1)), 0); return 1; }
public OnPlayerDisconnect(playerid, reason) { if(pVeh[playerid]) { DestroyVehicle(pVeh[playerid]); pVeh[playerid] = 0; } return 1; }
public OnVehicleSpawn(vehicleid) { for(new i = 0; i < MAX_PLAYERS; i++) { if(vehicleid != pVeh[i]) continue; DestroyVehicle(pVeh[i]); pVeh[i] = 0; break; } return 1; }
EDIT: ThePhenix's code will not work. It might work visually, but eventually you will realise that it's not working completely functionally.
|
Your code will work, but what if he wants to create two cars being spawned at the same time?
Re: Need help with car spawner -
Threshold - 06.08.2014
Then you just add an extra array onto pVeh.
Example:
pawn Код:
new pVeh[MAX_PLAYERS][5];
and edit accordingly.