19.03.2015, 11:36
Thats not as easy as you think.
You need an array to store the data:
I hope this helped you
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;
}
