Best text command type:ZCMD/YCMD(they look alike,it's up to your choice,I use ZCMD).
To make a dialog box follow this code:
The name is again up to your choice,you can even define it as BODEY_3333 1,but the number 1 represents the current dialog number you're coding,if you already had 2 more dialogues then it would be DIALOG_BOX 3,got it :P?Next we show the dialog,togheter with this,I'll show you a command also:
pawn Код:
COMMAND:showbox(playerid,params[])
{
ShowPlayerDialog(playerid,DIALOG_BOX,DIALOG_STYLE_MSGBOX,"Sample","Did you understand so far?","Yes","No");//We show the dialog for the player
return 1;
}
We must also end the dialog,this is done inside the OnDialogResponse function wich is already implemented in your script:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid==1)//We check the dialog's id wich represents DIALOG_BOX in this case
{
if(response==0)//They pressed the second button of the dialog wich is in most cases "No","Cancel","Abort"
{
SendClientMessage(playerid,COLOR_RED,"Action canceled!");
}
if(response==1)//They pressed the first button,wich is in most cases "Yes","OK",etc.(defined by you,ofc)
{
SendClientMessage(playerid,COLOR_GREEN,"I hope you understood dialogs!");
SendClientMessage(playerid,COLOR_GREEN,"Good luck!");
}
}
return 1;
}
Now you have seen 3 things put togheter,the best command system and its usage,the dialog box,and attaching a function to a command(in this case,showing the dialog),and now,the if statement.We will script a command that kills the player,but only if he is on foot AND NOT on a vehicle:
pawn Код:
COMMAND:kill(playerid,params[])
{
if(!IsPlayerInAnyVehicle(playerid)) return SetPlayerHealth(playerid,0);//Now,this statement checks if the player IS NOT on a vehicle,and if it's true,then it kill the player,but if not,then...
else//He IS on a vehicle
{
SendClientMessage(playerid,COLOR_RED,"You are in a vehicle,and you cannot kill yourself!);
}
return 1;
}
That's pretty much everything,I hope you understood.