20.06.2012, 05:48
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
i don't think it will work under OnDialogResponse... How can i make it dialog?
HEre's my Dialog command
and here OnDialogResponse (No idea how to do it all i got is this)
and here teleports you to nearest player
Any idea how to do it?
Would appreciate any help
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)
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;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
case DIALOG_ZCLASS:
{
if(!response) return ShowPlayerDialog(playerid,-1,0,"","","","");
if(response)
{
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;
}
Would appreciate any help