ayuda a terminar este codigo -
mcreed - 14.05.2015
bueno intente hacer un cуdigo para crear el comando /mochila pero no me salio nada bien, nose en que no me estoy fijando.
las id de las armas se guardan en la cuenta del usuario como "Weapon1","Weapon2","Weapon3". pero cuando el jugador tiene la mochila, le aparece que tiene armas, que bueno no a ni comprado ( un menu que yo cree ), en vez de aparecer "Sin Arma" aparece el nombre de un arma que nunca adquiriу.
Codigo /Mochila
pawn Код:
if(PlayerInfo[playerid][Mochila] == 1)
{
new yop[500];
new ArmaNombre[30],ArmaNombre2[30],ArmaNombre3[30];
if(PlayerInfo[playerid][Weapon1] == 0 || PlayerInfo[playerid][Weapon2] == 0 || PlayerInfo[playerid][Weapon3] == 0) ArmaNombre="Sin Arma"; ArmaNombre2="Sin Arma"; ArmaNombre3="Sin Arma";
if(PlayerInfo[playerid][Weapon1] == 38 || PlayerInfo[playerid][Weapon2] == 38 || PlayerInfo[playerid][Weapon3] == 38) ArmaNombre="Minigun"; ArmaNombre2="Minigun"; ArmaNombre3="Minigun";
if(PlayerInfo[playerid][Weapon1] == 35 || PlayerInfo[playerid][Weapon2] == 35 || PlayerInfo[playerid][Weapon3] == 35) ArmaNombre="Rocket"; ArmaNombre2="Rocket"; ArmaNombre3="Rocket";
if(PlayerInfo[playerid][Weapon1] == 36 || PlayerInfo[playerid][Weapon2] == 36 || PlayerInfo[playerid][Weapon3] == 36) ArmaNombre="HS Rocket"; ArmaNombre2="HS Rocket"; ArmaNombre3="HS Rocket";
if(PlayerInfo[playerid][Weapon1] == 16 || PlayerInfo[playerid][Weapon2] == 16 || PlayerInfo[playerid][Weapon3] == 16) ArmaNombre="Granadas"; ArmaNombre2="Granadas"; ArmaNombre3="Granadas";
if(PlayerInfo[playerid][Weapon1] == 18 || PlayerInfo[playerid][Weapon2] == 18 || PlayerInfo[playerid][Weapon3] == 18) ArmaNombre="Molotov"; ArmaNombre2="Molotov"; ArmaNombre3="Molotov";
format(yop,sizeof(yop),"{01A9DB}[1]{FFFFFF}Arma: %s\n{01A9DB}[2]{FFFFFF}Arma: %s\n{01A9DB}[3]{FFFFFF}Arma: %s",ArmaNombre,ArmaNombre2,ArmaNombre3);
ShowPlayerDialog(playerid,tienda_dialog,DIALOG_STYLE_LIST,"Mis Autos/Armas",yop,"Aceptar","Salir");
}
else { SendClientMessage(playerid,COLOR_RED,">> No Tienes Una Mochila"); }
return 1;
}
para dar el arma al jugador que la compra, cree una funcion donde solo tengo que poner
ArmaPremium(playerid,precio,armaid,municion)
Codigo de funcion:
pawn Код:
public ArmaPremium(playerid,precio,armaid,municion)
{
new STRBUY[500];
new STRALL[500];
new Client[MAX_PLAYER_NAME];
GetPlayerName(playerid,Client,sizeof(Client));
new ArmaNombre[30];
if(armaid == 38) ArmaNombre="Minigun";
if(armaid == 35) ArmaNombre="Rocket";
if(armaid == 36) ArmaNombre="HS Rocket";
if(armaid == 16) ArmaNombre="Granadas";
if(armaid == 18) ArmaNombre="Molotov";
if(PlayerInfo[playerid][Ammo1] > 0 && PlayerInfo[playerid][Ammo2] > 0 && PlayerInfo[playerid][Ammo3] > 0)
{
SendClientMessage(playerid,COLOR_RED,">> No Tienes Espacio Para Guadar El Arma");
}
if(PlayerInfo[playerid][Mochila] == 1)
{
if(GetPlayerMoney(playerid) >= precio)
{
if(PlayerInfo[playerid][Ammo1] == 0)
{
PlayerInfo[playerid][Weapon1] = armaid;
PlayerInfo[playerid][Ammo1] = municion;
GivePlayerWeapon(playerid,armaid,municion);
format(STRBUY,sizeof(STRBUY),"{FFFFFF}>> Ў DIOS MIO Ў TE HAS COMPRADO UNA {FE2E2E}%s,{FFFFFF} FOLLATE A TODOS",ArmaNombre);
format(STRALL,sizeof(STRALL),"{81F781}>> El Jugador {FFFFFF}%s{81F781} a Comprado Una {FFFFFF}%s {81F781}En La Tienda [ DIAMANTE ]",Client,ArmaNombre);
SendClientMessage(playerid,COLOR_YELLOW,STRBUY);
SendClientMessageToAll(COLOR_YELLOW,STRALL);
GivePlayerCash(playerid,-precio);
ArmasPre[playerid] = 1;
}
else if(PlayerInfo[playerid][Ammo2] == 0)
{
PlayerInfo[playerid][Weapon2] = armaid;
PlayerInfo[playerid][Ammo2] = municion;
GivePlayerWeapon(playerid,armaid,municion);
format(STRBUY,sizeof(STRBUY),"{FFFFFF}>> Ў DIOS MIO Ў TE HAS COMPRADO UNA {FE2E2E}%s,{FFFFFF} FOLLATE A TODOS",ArmaNombre);
format(STRALL,sizeof(STRALL),"{81F781}>> El Jugador {FFFFFF}%s{81F781} a Comprado Una {FFFFFF}%s {81F781}En La Tienda [ DIAMANTE ]",Client,ArmaNombre);
SendClientMessage(playerid,COLOR_YELLOW,STRBUY);
SendClientMessageToAll(COLOR_YELLOW,STRALL);
GivePlayerCash(playerid,-precio);
ArmasPre[playerid] = 1;
}
else if(PlayerInfo[playerid][Ammo3] == 0)
{
PlayerInfo[playerid][Weapon3] = armaid;
PlayerInfo[playerid][Ammo3] = municion;
GivePlayerWeapon(playerid,armaid,municion);
format(STRBUY,sizeof(STRBUY),"{FFFFFF}>> Ў DIOS MIO Ў TE HAS COMPRADO UNA {FE2E2E}%s,{FFFFFF} FOLLATE A TODOS",ArmaNombre);
format(STRALL,sizeof(STRALL),"{81F781}>> El Jugador {FFFFFF}%s{81F781} a Comprado Una {FFFFFF}%s {81F781}En La Tienda [ DIAMANTE ]",Client,ArmaNombre);
SendClientMessage(playerid,COLOR_YELLOW,STRBUY);
SendClientMessageToAll(COLOR_YELLOW,STRALL);
GivePlayerCash(playerid,-precio);
ArmasPre[playerid] = 1;
}
}
else
{
SendClientMessage(playerid,COLOR_RED,">> No Tienes Suficiente Dinero, Puedes Pedir Prestado a Un Amigo.");
}
}
else
{
if(GetPlayerMoney(playerid) >= precio)
{
GivePlayerWeapon(playerid,armaid,municion);
GivePlayerCash(playerid,-precio);
format(STRBUY,sizeof(STRBUY),"{FFFFFF}>> Ў DIOS MIO Ў TE HAS COMPRADO UNA {FE2E2E}%s,{FFFFFF} FOLLATE A TODOS",ArmaNombre);
format(STRALL,sizeof(STRALL),"{81F781}>> El Jugador {FFFFFF}%s{81F781} a Comprado Una {FFFFFF}%s {81F781}En La Tienda [ DIAMANTE ]",Client,ArmaNombre);
SendClientMessage(playerid,COLOR_YELLOW,STRBUY);
SendClientMessageToAll(COLOR_YELLOW,STRALL);
ArmasPre[playerid] = 1;
}
else { SendClientMessage(playerid,COLOR_RED,">> No Tienes Suficiente Dinero, Puedes Pedir Prestado a Un Amigo.");}
}
return 1;
}
Re: ayuda a terminar este codigo -
SickAttack - 14.05.2015
El problema es que no estas comparando que todos sus armas sean el mismo, y ademas deberнas comprobar cada uno, no al mismo tiempo.
Prueba esto:
pawn Код:
if(PlayerInfo[playerid][Mochila] == 1)
{
new string[500];
switch(PlayerInfo[playerid][Weapon1])
{
case 0: strcat(string, "[1] Arma: Sin Arma");
case 38: strcat(string, "[1] Arma: Minigun");
case 35: strcat(string, "[1] Arma: Rocket");
case 36: strcat(string, "[1] Arma: HS Rocket");
case 16: strcat(string, "[1] Arma: Granadas");
case 18: strcat(string, "[1] Arma: Molotov");
}
switch(PlayerInfo[playerid][Weapon2])
{
case 0: strcat(string, "\n[2] Arma: Sin Arma");
case 38: strcat(string, "\n[2] Arma: Minigun");
case 35: strcat(string, "\n[2] Arma: Rocket");
case 36: strcat(string, "\n[2] Arma: HS Rocket");
case 16: strcat(string, "\n[2] Arma: Granadas");
case 18: strcat(string, "\n[2] Arma: Molotov");
}
switch(PlayerInfo[playerid][Weapon3])
{
case 0: strcat(string, "\n[3] Arma: Sin Arma");
case 38: strcat(string, "\n[3] Arma: Minigun");
case 35: strcat(string, "\n[3] Arma: Rocket");
case 36: strcat(string, "\n[3] Arma: HS Rocket");
case 16: strcat(string, "\n[3] Arma: Granadas");
case 18: strcat(string, "\n[3] Arma: Molotov");
}
return ShowPlayerDialog(playerid, tienda_dialog, DIALOG_STYLE_LIST, "Mis Autos/Armas", string, "Aceptar", "Salir");
}
else return SendClientMessage(playerid,COLOR_RED,">> No Tienes Una Mochila");
Respuesta: ayuda a terminar este codigo -
OTACON - 15.05.2015
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;}