[Ajuda] Dialog com foreach
#2

Vк se й isso mano

PHP код:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT
#include <a_samp>
#include <foreach>
#include <zcmd>
#define MAX_SLOT            (5) // atй cinco jogadores armazenados
#define DIALOG_SELLITEM     (1)
new vString[128], MEGAString[512];
new 
PegarID[MAX_PLAYERS][MAX_SLOT],
    
PegarLista[MAX_PLAYERS][MAX_SLOT]
;
stock PlayerName(playerid)
{
    new 
pName[MAX_PLAYER_NAME];
    
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    return 
pName;
}
stock ResetPlayerVars(playerid)
{
    for(new 
slot; slot < MAX_SLOT; slot++)
    {
        
PegarID[playerid][slot] = -1;
        
PegarLista[playerid][slot] = -1;
    }
    return 
1;
}
public 
OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(
dialogid == DIALOG_SELLITEM)
    {
        if(
response)
        {
            if(
listitem == PegarLista[playerid][listitem])
            {
                new 
i = PegarID[playerid][listitem];
                
format(vString, 128, "Vocк clicou em: %s[%d]", PlayerName(i), i);
                
SendClientMessage(playerid,-1, vString);
                return 
1;
            }
        }
        
// reset caso click em cancelar
        
ResetPlayerVars(playerid);
    }
    return 
1;
}
CMD:teste(playerid, params[])
{
    new 
Float:x, Float:y, Float:z, playerProx;
    
GetPlayerPos(playerid, x, y, z);
    
ResetPlayerVars(playerid)
    foreach(
Player, i)
    {
        if(
IsPlayerInRangeOfPoint(i, 5.0, x, y, z))
        {
            
MEGAString[0] = EOS;
            
format(vString, sizeof(vString), "%s (ID: %d)", PlayerName(i), i);
            
strcat(MEGAString, vString);
                
playerProx++;
            for(new 
slot = 0; slot < MAX_SLOT; ++slot)
            {
                if(
PegarLista[playerid][slot] != -1)
                {
                    
PegarLista[playerid][slot] = slot;// Aqui ele pegara a listitem
                    
PegarID[playerid][slot] = i;// aqui pegara o ID
                    
break;
                }
            }
        }
        if(
playerProx == 0) return SendClientMessage(playerid, -1, " Ninguйm estб prуximo de vocк.");
        
ShowPlayerDialog(i, DIALOG_SELLITEM, DIALOG_STYLE_LIST, "Vender item", MEGAString, "Selecionar", "Voltar");
        return 
1;
     }
     return 
1;
}
public 
OnFilterScriptInit()
{
    print(
"\n--------------------------------------");
    print(
" Blank Filterscript by your name here");
    print(
"--------------------------------------\n");
    return 
1;
}
public 
OnFilterScriptExit()
{
    return 
1;
} 
@edit
Reply


Messages In This Thread
Dialog com foreach - by pWesley - 26.07.2016, 03:58
Respuesta: Dialog com foreach - by SammyJ - 26.07.2016, 04:41
Re: Dialog com foreach - by pWesley - 26.07.2016, 17:29
Respuesta: Dialog com foreach - by SammyJ - 26.07.2016, 17:34
Re: Dialog com foreach - by pWesley - 26.07.2016, 17:39
Respuesta: Dialog com foreach - by SammyJ - 26.07.2016, 17:43
Re: Dialog com foreach - by pWesley - 26.07.2016, 18:07
Respuesta: Dialog com foreach - by SammyJ - 26.07.2016, 18:15
Re: Dialog com foreach - by pWesley - 26.07.2016, 18:26

Forum Jump:


Users browsing this thread: 1 Guest(s)