15.05.2015, 08:03
(
Последний раз редактировалось OTACON; 15.05.2015 в 09:59.
)
PHP код:
#include <a_samp>
#include <zcmd>
#define DIALOG_MOCHILA (1)
#define MAX_SLOTS (10)
enum a_armas{
armas_guardadas[MAX_SLOTS],
municion_guardadas[MAX_SLOTS],
bool:slots_usado[MAX_SLOTS],
bool:con_mochila,
};
new InfoMochila[MAX_PLAYERS][a_armas];
stock menu_Mochila(playerid){
new data[1024], //esto lo debes cambiar, obvio -.-
datos[1024],//esto lo debes cambiar, obvio -.-
gunname[32];
strcat(datos, "Slots\tArma\tMunicion\n");
for(new index=0; index<MAX_SLOTS; index++){
new armaid = InfoMochila[playerid][armas_guardadas][index];
if(InfoMochila[playerid][slots_usado][index]) GetWeaponName(armaid,gunname,sizeof(gunname));
else gunname = "vacio";
format(data,sizeof(data),"slot:(%d)\t%s\t%d balas\n", index, gunname, InfoMochila[playerid][municion_guardadas][index]);
strcat(datos, data);
}
ShowPlayerDialog(playerid, DIALOG_MOCHILA+0, DIALOG_STYLE_TABLIST_HEADERS, "Mochila:",datos,"seleccionar", "cancelar");
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
switch(dialogid){
case DIALOG_MOCHILA+0:{
if(response){
if(!InfoMochila[playerid][slots_usado][listitem]){ //guardar
if(GetPlayerWeapon(playerid)<=0){ menu_Mochila(playerid);return true; }
InfoMochila[playerid][armas_guardadas][listitem] = GetPlayerWeapon(playerid);
InfoMochila[playerid][municion_guardadas][listitem] = GetPlayerAmmo(playerid);
ResetPlayerWeaponsEx(playerid, GetPlayerWeapon(playerid));
SetPlayerArmedWeapon(playerid,0);
InfoMochila[playerid][slots_usado][listitem] = true;
menu_Mochila(playerid);
}else{ // equipar
GivePlayerWeapon(playerid, InfoMochila[playerid][armas_guardadas][listitem] ,InfoMochila[playerid][municion_guardadas][listitem]);
SetPlayerAmmo(playerid, InfoMochila[playerid][armas_guardadas][listitem] ,InfoMochila[playerid][municion_guardadas][listitem]);
InfoMochila[playerid][armas_guardadas][listitem] = 0;
InfoMochila[playerid][municion_guardadas][listitem] = 0;
InfoMochila[playerid][slots_usado][listitem] = false;
menu_Mochila(playerid);
}
}
}
}
return false;
}
COMMAND:mochila(playerid, params[]){
menu_Mochila(playerid);
return true;
}
PHP код:
stock ResetPlayerWeaponsEx(playerid, weaponid){
new weapons[13][2];
for (new slots=0; slots<13; slots++){
if(slots==GetWeaponSlot(weaponid))continue;
GetPlayerWeaponData(playerid, slots, weapons[slots][0], weapons[slots][1]);
}ResetPlayerWeapons(playerid);
for (new slots=0; slots<13; slots++){
GivePlayerWeapon(playerid, weapons[slots][0], weapons[slots][1]);
SetPlayerAmmo(playerid, weapons[slots][0], weapons[slots][1]);
}}
stock GetWeaponSlot(weaponid){
new slots;
switch(weaponid){
case 0,1: slots = 0;
case 2..9: slots = 1;
case 10..15: slots = 10;
case 16..18,39: slots = 8;
case 22..24: slots = 2;
case 25..27: slots = 3;
case 28,29,32: slots = 4;
case 30,31: slots = 5;
case 33,34: slots = 6;
case 35..38: slots = 7;
case 40: slots = 12;
case 41..43: slots = 9;
case 44..46: slots = 11;
}return slots;}