19.03.2011, 19:53
Using ZCMD... (you can get zcmd by clicking this link)
Now an explaination...
We have to
Then I used the color red but I dont want to have to put 0xFF0000FF so instead I define it at the top.
For more colors create them HERE and place them between the 0x...FF .
Now under your publics or if you find where you commands, place the
under them.
Now after we have that settled we must make our actual dialog box.
And this ofcourse you can make room for in the Public OnDialogResponse callback!
Resources:
wiki.sa-mp.com
https://sampwiki.blast.hk/wiki/SendClientMessage
https://sampwiki.blast.hk/wiki/SendClientMessageToAll
https://sampwiki.blast.hk/wiki/ShowPlayerDialog
https://sampwiki.blast.hk/wiki/OnDialogResponse
And many tutorial LOCATED HERE.
pawn Код:
#include <zcmd>
#define ColorRed 0xFF0000FF
CMD:teleport(playerid,params[])
{
SendClientMessage(playerid,ColorRed,"So you would like to teleport, please select one of our various locations!");
ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Teleports","Los Santos\r\nSan Fierro\r\nLas Venturas","Teleport", "Nevermind.");
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1)
{
case 1:
{
if(!response)
{
SendClientMessage(playerid,ColorRed,"You cancelled.");
return 1;
}
switch(listitem)
{
case 0:
{
SetPlayerPos(playerid,X,Y,Z);
SetPlayerFacingAngle(playerid,A)
SendClientMessage(playerid,ColorRed,"You have teleported to Los Santos!")
new pname[24],message[128];
GetPlayerName(playerid,pname,24);
format(message, sizeof(message),"[Teleport]: %s has teleported to Los Santos!",playername);
SendClientMessageToAll(playerid,ColorRed,message)
}
case 1:
{
SetPlayerPos(playerid,X,Y,Z);
SetPlayerFacingAngle(playerid,A)
SendClientMessage(playerid,ColorRed,"You have teleported to San Fierro!")
new pname[24],message[128];
GetPlayerName(playerid,pname,24);
format(message, sizeof(message),"[Teleport]: %s has teleported to San Fierro!",playername);
SendClientMessageToAll(playerid,ColorRed,message)
}
case 2:
{
SetPlayerPos(playerid,X,Y,Z);
SetPlayerFacingAngle(playerid,A)
SendClientMessage(playerid,ColorRed,"You have teleported to Las Venturas!")
new pname[24],message[128];
GetPlayerName(playerid,pname,24);
format(message, sizeof(message),"[Teleport]: %s has teleported to Las Venturas!",playername);
SendClientMessageToAll(playerid,ColorRed,message)
}
}
}
}
return 0;
}
We have to
pawn Код:
#include <zcmd>
// This is what I used for the command, its how I create commands on my server!
pawn Код:
#define ColorRed 0xFF0000FF
Now under your publics or if you find where you commands, place the
pawn Код:
CMD:teleport(playerid,params[])
{
SendClientMessage(playerid,ColorRed,"So you would like to teleport, please select one of our various locations!"); //sends a message so he/she knows what to do.
ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Teleports","Los Santos\r\nSan Fierro\r\nLas Venturas","Teleport", "Nevermind."); //show the player the dialogbox
}
Now after we have that settled we must make our actual dialog box.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1) //this gets the dialog box id.
{
case 1:
{
if(!response) // if player hits nevermind.
{
SendClientMessage(playerid,ColorRed,"You cancelled.");
return 1;
}
switch(listitem) // this is important
{
case 0: //our first item Los Santos
{
SetPlayerPos(playerid,X,Y,Z); // the x y z location that the player ports to
SetPlayerFacingAngle(playerid,A) // where do you want him to be facing?
SendClientMessage(playerid,ColorRed,"You have teleported to Los Santos!") // sends a client message to the player that he successfully teleported.
new pname[24],message[128];
GetPlayerName(playerid,pname,24);
format(message, sizeof(message),"[Teleport]: %s has teleported to Los Santos!",playername);
SendClientMessageToAll(playerid,ColorRed,message) // it will send a message to all players that he teleported.
}
case 1: // the second option San Fierro
{
SetPlayerPos(playerid,X,Y,Z);
SetPlayerFacingAngle(playerid,A)
SendClientMessage(playerid,ColorRed,"You have teleported to San Fierro!")
new pname[24],message[128];
GetPlayerName(playerid,pname,24);
format(message, sizeof(message),"[Teleport]: %s has teleported to San Fierro!",playername);
SendClientMessageToAll(playerid,ColorRed,message)
}
case 2: // the third option Las Venturas
{
SetPlayerPos(playerid,X,Y,Z);
SetPlayerFacingAngle(playerid,A)
SendClientMessage(playerid,ColorRed,"You have teleported to Las Venturas!")
new pname[24],message[128];
GetPlayerName(playerid,pname,24);
format(message, sizeof(message),"[Teleport]: %s has teleported to Las Venturas!",playername);
SendClientMessageToAll(playerid,ColorRed,message)
}
}
}
}
return 0; // return 0...
}
Resources:
wiki.sa-mp.com
https://sampwiki.blast.hk/wiki/SendClientMessage
https://sampwiki.blast.hk/wiki/SendClientMessageToAll
https://sampwiki.blast.hk/wiki/ShowPlayerDialog
https://sampwiki.blast.hk/wiki/OnDialogResponse
And many tutorial LOCATED HERE.