Dialog to Callbacks? Comeon anyone?
#1

Hey guys how can i do something like this.
I have a dialog, if you are zombie and you type /class it will show you DIALOG_STYLE_LIST with 2 lists
so if the player selects the first one then it teleports him to the nearest player i have all this but i want to do it with dialog and to teleport to nearest player it needs a Callbacks/Function this one
pawn Код:
forward GetClosestPlayerToPlayer(playerid);
public GetClosestPlayerToPlayer(playerid)
i don't think it will work under OnDialogResponse... How can i make it dialog?
HEre's my Dialog command
pawn Код:
command(Class,playerid,params[])
{
    if(gTeam[playerid] == Zombie)
    {
        ShowPlayerDialog(playerid, ZCLASS, DIALOG_STYLE_LIST, "Class Selection", "{FF0000}Bite(30HP)\n{00FF00}High Jump", "Select", "Cancle");
    }
    else if(gTeam[playerid] == Vampire)
    {
        ShowPlayerDialog(playerid, VCLASS, DIALOG_STYLE_LIST, "Class Selection", "{FF0000}Bite (30HP)\n{00FF00}Tp to nearest player", "Select", "Cancle");
    }
    return 1;
}
and here OnDialogResponse (No idea how to do it all i got is this)
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    case DIALOG_ZCLASS:
    {
        if(!response) return ShowPlayerDialog(playerid,-1,0,"","","","");
        if(response)
        {
and here teleports you to nearest player
pawn Код:
forward GetClosestPlayerToPlayer(playerid);
public GetClosestPlayerToPlayer(playerid)
{
    new Float:dist = 1000.0;
    new targetid = INVALID_PLAYER_ID;
    new Float:x1,Float:y1,Float:z1;
    new Float:x2,Float:y2,Float:z2;
    new Float:tmpdis;
    GetPlayerPos(playerid,x1,y1,z1);
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if(i == playerid) continue;
        GetPlayerPos(i,x2,y2,z2);
        tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
        if(tmpdis < dist)
        {
            dist = tmpdis;
            targetid = i;
        }
    }
    return targetid;
}
Any idea how to do it?
Would appreciate any help
Reply
#2

anyone? I'm really need it :S
Reply
#3

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    case DIALOG_ZCLASS:
    {
        if(!response) return ShowPlayerDialog(playerid,-1,0,"","","","");
        if(response)
        {
        switch(listitem)// Checking which listitem was selected
            {
                case 0:
                {
                    if(gTeam[playerid] == Zombie)
                    {
                        new id =  GetClosestPlayerToPlayer(playerid);
                        new Float:x,Float:y,Float:z;
                        GetPlayerPos(id,x,y,z);
                        SetPlayerPos(playerid,x,z,z);
                    }
                   
                case 1:
                {
                    //Whatever you want in case 1
                }
               
            }
        }
    }
}
Reply
#4

Oh thanks man i'll test it out
Reply
#5

Or you can use OnPlayerGiveDamage.

If the playerid is from a zombie player, juste put the targetid in the zombie team.
Reply
#6

@Raxor, Nope it needs "switch (dialogid)" and when i add it, it gives errors "Undefined Symbol" GetClosestPlayerToPlayer.
Reply
#7

Quote:
Originally Posted by Rudy_
Посмотреть сообщение
@Raxor, Nope it needs "switch (dialogid)" and when i add it, it gives errors "Undefined Symbol" GetClosestPlayerToPlayer.
Sorry, my bad
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
    case DIALOG_ZCLASS:
    {
        if(!response) return ShowPlayerDialog(playerid,-1,0,"","","","");
        if(response)
        {
            switch(listitem)// Checking which listitem was selected
            {
                case 0:
                {
                    if(gTeam[playerid] == Zombie)
                    {
                        new id =  GetClosestPlayerToPlayer(playerid);
                        new Float:x,Float:y,Float:z;
                        GetPlayerPos(id,x,y,z);
                        SetPlayerPos(playerid,x,z,z);
                    }
                }
                case 1:
                {
                    //Whatever you want in case 1
                }
            }
        }
    }
    }
}
Reply
#8

I already did this, it says "Undefined symbol GetClosestPlayerToPlayer"
I defined it also.. still
Reply
#9

pawn Код:
#define DIALOG_ZCLASS 1
#define DIALOG_VCLASS 2

command(Class,playerid,params[])
{
    if(gTeam[playerid] == Zombie)
    {
        ShowPlayerDialog(playerid, DIALOG_ZCLASS, DIALOG_STYLE_LIST, "Class Selection", "{FF0000}Bite(30HP)\n{00FF00}High Jump", "Select", "Cancle");
    }
    else if(gTeam[playerid] == Vampire)
    {
        ShowPlayerDialog(playerid, DIALOG_VCLASS, DIALOG_STYLE_LIST, "Class Selection", "{FF0000}Bite (30HP)\n{00FF00}Tp to nearest player", "Select", "Cancle");
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
    case DIALOG_ZCLASS :
    {
        if(!response) return ShowPlayerDialog(playerid,-1,0,"","","","");
        if(response)
        {
            switch(listitem)// Checking which listitem was selected
            {
                case 0:
                {

                        new id =  GetClosestPlayerToPlayer(playerid);
                        new Float:x,Float:y,Float:z;
                        GetPlayerPos(id,x,y,z);
                        SetPlayerPos(playerid,x,z,z);

                }
                case 1:
                {
                    //Whatever you want in case 1
                }
            }
        }
    }
    }
    return 1;
}
pawn Код:
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase
I checked this code , works fine.
Reply
#10

lol and it's not working for me..
Btw
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_ZCLASS:
        {
            if(!response) return ShowPlayerDialog(playerid,-1,0,"","","","");
            if(response)
            {
            switch(listitem)
                {
                case 0:
                {
                    if(gTeam[playerid] == Zombie)
                    {
                        new id =  GetClosestPlayer(id);
                        new Float:x,Float:y,Float:z;
                        GetPlayerPos(id,x,y,z);
                        SetPlayerPos(playerid,x,z,z);
                    }
                    case 1:
                    {

                    }
            }
        }
    }
    return 1;
}

        case DIALOG_VCLASS:
        {
            if(!response) return ShowPlayerDialog(playerid,-1,0,"","","","");
            if(response)
            {
            switch(listitem)
                {
                case 0:
                {
                    if(gTeam[playerid] == Vampire)
                    {
                        new id =  GetClosestPlayer(id);
                        new Float:x,Float:y,Float:z;
                        GetPlayerPos(id,x,y,z);
                        SetPlayerPos(playerid,x,z,z);
                    }
                    case 1:
                    {

                    }
                }
            }
        }
    }
}
and errors
Код:
C:\Users\Pepsi\Desktop\Scripting\gamemodes\Scripter.pwn(533) : error 014: invalid statement; not in switch
C:\Users\Pepsi\Desktop\Scripting\gamemodes\Scripter.pwn(533) : warning 215: expression has no effect
C:\Users\Pepsi\Desktop\Scripting\gamemodes\Scripter.pwn(533) : error 001: expected token: ";", but found ":"
C:\Users\Pepsi\Desktop\Scripting\gamemodes\Scripter.pwn(533) : error 029: invalid expression, assumed zero
C:\Users\Pepsi\Desktop\Scripting\gamemodes\Scripter.pwn(533) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)