car inventory - 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)
+--- Thread: car inventory (
/showthread.php?tid=568095)
car inventory -
Eestlane123 - 19.03.2015
Sorry for my bad english.
I want that the people can put their gun to car.
/putgun - can put gun to inventori
/takegun - can take gun from inventori
/inv - can look inventori
I dont know hot to make this, i use zcmd
AW: car inventory -
Kaliber - 19.03.2015
Thats not as easy as you think.
You need an array to store the data:
PHP код:
#define MAX_GUNS_IN_CAR 5
enum v_E {
vMunni[MAX_GUNS_IN_CAR],
vGun[MAX_GUNS_IN_CAR]
};
new vInfo[MAX_VEHICLES][v_E];
//in the put command:
//Check that the weaponid is not 0!!
if(!gun) return SCM(playerid,-1,"You have no weapon!"); //This is important
new v = GetVehicleInRange(playerid);
if(v == INVALID_VEHICLE_ID) return SCM(playerid,-1,"There is no vehicle in your range!");
new bool:z;
for(new i; i<MAX_GUNS_IN_CAR; i++)
{
if(vInfo[v][vGun][i] == 0)
{
vInfo[v][vGun][i] = gun;
vInfo[v][vMunni][i] = munni;
z=true;
break;
}
}
if(!z) return SCM(playerid,-1,"The Vehicle is full of guns!");
//Then reset the gun for the player
//for the get command:
//he must give a slot:
new slot = strval(params);
if(!(0 <= slot <= MAX_GUNS_IN_CAR)) return SCM(playerid,-1,"This slot is not available!");
new v = GetVehicleInRange(playerid);
if(v == INVALID_VEHICLE_ID) return SCM(playerid,-1,"There is no vehicle in your range!");
if(vInfo[v][vGun][slot] == 0) return SCM(playerid,-1,"This slot is empty!");
GivePlayerWeapon(playerid,vInfo[v][vGun][slot],vInfo[v][vMunni][slot]);
vInfo[v][vGun][slot] = 0;
//Here is the function:
stock GetVehicleInRange(playerid) {
new Float:p[3],i;
for(; i<MAX_VEHICLES; i++) {
GetVehiclePos(i,p[0],p[1],p[2]);
if(IsPlayerInRangeOfPoint(playerid,3.5,p[0],p[1],p[2])) return i;
}
return INVALID_VEHICLE_ID;
}
I hope this helped you