only one vehicle allowed -
jamesbond007 - 05.12.2009
how can i make that only one vehicle allowed to spawn for a player?
lets say they type /nrg so they spawn a nrg-500 but if they type that command multiple times i will have a mess of vehicles on my server so how can i put so only one vehicle allowed to spawn?
Re: only one vehicle allowed -
DJDhan - 05.12.2009
Mmm

Most of the vehicles are respawned replacing the existing one if spawned at the same place.
Maybe you need a vehicle destroying system.Or use a timer as to how much time a player has to wait before they can spawn a vehcile again.

And also check if he is already in a vehicle or not an stuff.
Dhananjay
Re: only one vehicle allowed -
Lajko1 - 05.12.2009
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/nrg", true) == 0)
{
CreateVehicle(nrgid,x,y,z,colors etc);
SpawnedNRG[playerid] == 1
if(SpawnedNRG[playerid] == 1
{
sendclientmessage(playerid,color,"You Already Spawn 1 NRG");
}
return 1;
}
actualy its not 100% right command but you can make way like this ... i hope i helped
EDIT: ye i forgot 1 bracket ...
Re: only one vehicle allowed -
DJDhan - 05.12.2009
Lajko1,wouldn't this code allow any player to spawn a nrg only once untill the player dies .You also have reset the value of spawnednrg to 0.
But hey players might need the nrg more than once
So basically a timer maybe better.And when the vehicle is spawned again,check if the previous vehicle health is 0,otherwise destroy it!
Re: only one vehicle allowed -
Lajko1 - 05.12.2009
actualy you are right but i am not good scripter but show just a litle way how you can do this with this things NRGspawn[playerid] == 1 or 0 etc
Re: only one vehicle allowed -
DJDhan - 05.12.2009
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if((strcmp(cmdtext, "/nrg", true) == 0) && IsPlayerInAnyVehicle(playerid))
{
CreateVehicle(nrgid,x,y,z,colors etc);
SpawnedNRG[playerid] == ]
if(SpawnedNRG[playerid] == 1]
{
sendclientmessage(playerid,color,"You Already Spawn 1 NRG");
}
return 1;
}
Maybe you can add a parameter no.of nrg's spawned and name them (playerid,nrg1) etc... and then increment it everytime you type /nrg
Or maybe add max no of vehicles a player can spawn in defined time...
It is really easy if a player is in a vehicle.
Otherwise use a good vehicle destroying system that's all.
There are lot of them here.Just search.
Can't help any further
Re: only one vehicle allowed -
KnooL - 05.12.2009
pawn Код:
enum pPlayerInfo
{
SpawnedNRG
};
new PlayerInfo[MAX_PLAYERS][pPlayerInfo];
public OnPlayerCommandText(playerid, cmdtext[])
{
if((strcmp(cmdtext, "/nrg", true) == 0)
{
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
CreateVehicle(nrgid,X,Y,Z,colors etc);
PlayerInfo[player][SpawnedNRG] = 1;
}
if (PlayerInfo[player][SpawnedNRG] == 1)
{
if (IsPlayerInVehicle(playerid))
{
DestroyVehicle(GetPlayerVehicleID(playerid));
}
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
CreateVehicle(nrgid,x,y,z,colors etc);
}
else if(IsPlayerInVehicle(playerid))
{
DestroyVehicle(GetPlayerVehicleID(playerid));
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
CreateVehicle(nrgid,x,y,z,colors etc);
}
return 1;
}
Haven't tried this out, I believe it works. Tell me if there is something that holds up.
Re: only one vehicle allowed -
jamesbond007 - 06.12.2009
sorry but non of those are working^^ bump
Re: only one vehicle allowed -
lolumadd - 06.12.2009
When he spawns a vehicle set a boolean variable set to true.
When he try's to spawn another vehicle check if it is set to true. If it is, use a return to stop the code.