car inventory
#1

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

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 GetVehicleInRange(playerid);
if(
== INVALID_VEHICLE_ID) return SCM(playerid,-1,"There is no vehicle in your range!");
new 
bool:z;
for(new 
ii<MAX_GUNS_IN_CARi++)
{
    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(!(
<= slot <= MAX_GUNS_IN_CAR)) return SCM(playerid,-1,"This slot is not available!");
new 
GetVehicleInRange(playerid);
if(
== 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_VEHICLESi++) {
        
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)