Getting Vehicleid after CreateVehicle
#1

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...
Reply
#2

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

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

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
Reply
#5

thank you swift
it works^-^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)