SA-MP Forums Archive
Getting Vehicleid after CreateVehicle - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Getting Vehicleid after CreateVehicle (/showthread.php?tid=82781)



Getting Vehicleid after CreateVehicle - saiberfun - 20.06.2009

pawn Код:
new cg;
cg = CreateVehicle(522,vvx[playerid],vvy[playerid],vvz[playerid],vvr[playerid],AccountInfo[playerid][Color1],AccountInfo[playerid][Color2],10000000000000000000000);
PutPlayerInVehicle(playerid,cg,0);
i need to kno how to get the vehicleid of the createdvehicle...

i tried it with:

pawn Код:
//on top of the script
new ownedv[playerid];
//CreateVehicleFuntion  
new cg;
cg = CreateVehicle(522,vvx[playerid],vvy[playerid],vvz[playerid],vvr[playerid],AccountInfo[playerid][Color1],AccountInfo[playerid][Color2],10000000000000000000000);
PutPlayerInVehicle(playerid,cg,0);
ownedv[playerid] = GetPlayerVehicleID(playerid);
and when i used the ownedv[playerid] in other functions like

pawn Код:
DestroyVehicle(ownedv[playerid]);

nothin happends...


Re: Getting Vehicleid after CreateVehicle - Grim_ - 20.06.2009

Make cg; global. (to of script).
And then use
pawn Код:
DestroyVehicle(cg);



Re: Getting Vehicleid after CreateVehicle - saiberfun - 20.06.2009

Quote:
Originally Posted by Swift_
Make cg; global. (to of script).
And then use
pawn Код:
DestroyVehicle(cg);
but cg = createvehicle
not the vehicleid :/


Re: Getting Vehicleid after CreateVehicle - Grim_ - 20.06.2009

CreateVehicle returns the vehicleid of the vehicle created and since you used the cg variable for CreateVehicle, it holds the valuable of the CreatedVehicle, which would be the ID. So yes, it will work, trust me


Re: Getting Vehicleid after CreateVehicle - saiberfun - 20.06.2009

thank you swift
it works^-^