Need Help with car spawner. -
MBilal - 27.11.2015
Код:
SpawnVipVehicle(playerid,level,vehicleid )
{
if(pInfo[playerid][Donator] < level )return SCM(playerid,COLOR_AQUA, "You are not authorized to use this command.");
if(SpawnedVIP[playerid] == 1 && myCar[playerid] == VipVeh[playerid]) DestroyVehicle(myCar[playerid]) ,SpawnedVIP[playerid]=0;
if(IsPlayerInAnyVehicle(playerid))return SCM(playerid,0x00FF00AA,NOT_INVEH_MSG);
new Float:pX,Float:pY,Float:pZ,Float:pw;
GetPlayerPos(playerid, pX,pY,pZ);
GetPlayerFacingAngle(playerid, pw);
myCar[playerid] = CreateVehicle(vehicleid, pX, pY, pZ, pw, 0, 0, 0);
PutPlayerInVehicle(playerid, myCar[playerid], 0);
VipVeh[playerid] = GetPlayerVehicleID(playerid);
SpawnedVIP[playerid]=1;
return 1;
}
CMD:vheli(playerid, params[])return SpawnVipVehicle(playerid,3,487);
The problem is coming when any player spawn vehicle and another player also spawn vehicle.....
it remove first player vehicle and spawn 2nd one vehicle.......
Why its happening how to Fix that?
Kindly Help.
Thanks.
Re: Need Help with car spawner. -
TwinkiDaBoss - 28.11.2015
You are assigning mycar to playerid and limiting him to spawn only 1 vehicle, aka you are storing same vehicle into same variable. Since you are making player be able to spawn multiple vehicles, you can do something like this
pawn Код:
SpawnVipVehicle(playerid,level,vehicleid )
{
if(pInfo[playerid][Donator] < level )return SCM(playerid,COLOR_AQUA, "You are not authorized to use this command.");
if(SpawnedVIP[playerid] == 1 && myCar[playerid] == VipVeh[playerid]) DestroyVehicle(myCar[playerid]) ,SpawnedVIP[playerid]=0;
if(IsPlayerInAnyVehicle(playerid))return SCM(playerid,0x00FF00AA,NOT_INVEH_MSG);
if(SpawnedCars[playerid] >= 11) return SCM(playerid,COLOR_RED,"You have spawned 10 vehicles already");
new Float:pX,Float:pY,Float:pZ,Float:pw;
SpawnedCars[playerid] += 1; //we are adding up on how many cars he spawned.
GetPlayerPos(playerid, pX,pY,pZ);
GetPlayerFacingAngle(playerid, pw);
VipVeh[playerid] = GetPlayerVehicleID(playerid);
SpawnedVIP[playerid]=1;
if(SpawnedCars[playerid] == 1) { CarID[playerid][0] = CreateVehicle(vehicleid, pX, pY, pZ, pw, 0, 0, 0); }
else if(SpawnedCars[playerid] == 2) { CarID[playerid][1] = CreateVehicle(vehicleid, pX, pY, pZ, pw, 0, 0, 0); }
//etc etc etc
return 1;
}
new
SpawnedCars[MAX_PLAYERS], //save how many cars he spawned
CarID[MAX_PLAYERS][10]; // its where we are going to store our vehicles. This way max 10 vehicles
This isnt really efficiant but it does the work
Re: Need Help with car spawner. -
MBilal - 28.11.2015
Dude i am not talkng about limiting player vehicle .
Read this :
The problem is coming when any player spawn vehicle and another player also spawn vehicle .....
it remove first player vehicle and spawn 2nd player vehicle.......
Why it remove First Player Vehicle......? When any other player spawn vehicle.
Re: Need Help with car spawner. -
jlalt - 28.11.2015
Well, as i see nothing destroying vehicle in your above code,try to find where destroyvehicle(myCar[playerid]); called?