ShowPlayerDialog
#4

Quote:
Originally Posted by [ISS]jumbo
Посмотреть сообщение
pawn Код:
//You show a dialog with id 5
if(strcmp(cmdtext, "/cmds", true) == 0)
{
    ShowPlayerDialog(playerid, 5, DIALOG_STYLE_MSGBOX, "{00FFFF}Commands", "/bones - It changes body parts for the holds, It needs num4 & num6\n/buyweapons - Buy some cheap weapons\n/carmenu - Vehicles Gategories\n/cartune - Tune the car\n/changeskin <id> - Change Skin\n/g <name/id> - Teleport to a player/bot\n/help - If you want some help!\n/hold <modelid> - Hold objects\n/jetpack - Spawn jetpack\n/kill - Suicide\n* Kostas' - The command itself\n/neon - Set neon on under your car", "Next", "Cancel");
    return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    //if the dialog is the dialog with id 5
    if(dialogid == 5)
    {
        //if response so if player press Next
        if(response)
        {
            //show the dialog with id 6
            ShowPlayerDialog(playerid, 6, DIALOG_STYLE_MSGBOX, "{00FFFF}Commands", "/para or /parachute - Spawn parachute\n/search - Type a word and it searchs for possible holds  'ex: hat'\n/ssb 1-3 - it set SpeedBoost on your car <1 - off, 2 - medium, 3 - high>/time 0-23 - Change time 0 to 23\n/teles - See the teleports\n/v [part of name] - Spawn a vehicle. Note: You can use /v [part of name] <color1> <color2>\n/vcontrol - Control you car <Alarm, Bonnet, Boot, Doors, Engine, Lighting>", "Back", "Cancel");
        }
    }
    //if the dialog is the dialog with id 6
    if(dialogid == 6)
    {
        //and player press back
        if(response)
        {
            //show the frist idialog
            ShowPlayerDialog(playerid, 5, DIALOG_STYLE_MSGBOX, "{00FFFF}Commands", "/bones - It changes body parts for the holds, It needs num4 & num6\n/buyweapons - Buy some cheap weapons\n/carmenu - Vehicles Gategories\n/cartune - Tune the car\n/changeskin <id> - Change Skin\n/g <name/id> - Teleport to a player/bot\n/help - If you want some help!\n/hold <modelid> - Hold objects\n/jetpack - Spawn jetpack\n/kill - Suicide\n* Kostas' - The command itself\n/neon - Set neon on under your car", "Next", "Cancel");
        }
    }
    return 1;
}
First of all, this I will keep it or should remove it
pawn Код:
if (strcmp(cmdtext, "/cmds2", true) == 0) {
        ShowPlayerDialog(playerid, 6, DIALOG_STYLE_MSGBOX, "{00FFFF}Commands", "/para or /parachute - Spawn parachute\n/search - Type a word and it searchs for possible holds  'ex: hat'\n/ssb 1-3 - it set SpeedBoost on your car <1 - off, 2 - medium, 3 - high>/time 0-23 - Change time 0 to 23\n/teles - See the teleports\n/v [part of name] - Spawn a vehicle. Note: You can use /v [part of name] <color1> <color2>\n/vcontrol - Control you car <Alarm, Bonnet, Boot, Doors, Engine, Lighting>", "Cancel", "OK");
        return 1;
    }
If I should remove it I got this error.
pawn Код:
C:\Documents and Settings\orion\Фб ЭггсбцЬ мпх\Downloads\samp03csvr_R2-2_win32 (2)\gamemodes\Xtreamgaming.pwn(6491) : error 075: input line too long (after substitutions)
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
I leave it and compile it and I got 6 errors.

================================================== =====================


Quote:
Originally Posted by Rachael
Посмотреть сообщение
There are a number of ways to do this. Here is a way which will make it easier if / when you add new commands to your script.

First, create a global variable.
Naturally you will have to put in your own commands and descriptions.
pawn Код:
new ComGeneral[][] =
{
    { "/login" },
    { "/logout" },
    { "/logkill" },
    { "/kill" },
    { "/register" },
    { "/forum" },
    { "/accept" },
    { "/cancel" },
    { "/graph" },
    { "/joinballas" },
    { "/joinvagos" },
    { "/spawnchange" },
    { "/buyhouse" },
    { "/sellhouse" },
    { "/houseinvite" },
    { "/v" },
    { "/givekey" },
    { "/lock" },
    { "/unlock" },
    { "/winch" },
    { "/join" },
    { "/quitjob" },
    { "/report" },
    { "/paycheck" },
    { "/signcheck" },
    { "/service" },
    { "/lotto" },
    { "/fish" }
};
Then you can use string processing to construct the dialog.
If I were doing it, I would use the list style
pawn Код:
if( !strcmp( cmdtext , "/cmds" , true ) )
{
    new
        dialog[512],
        part[36]
    ;
    format( dialog , sizeof(dialog) , "{FFFFFF}%s" , ComGeneral[0] );
    for( new i = 1; i < sizeof( ComGeneral ); i++ )
    {
        format( part , sizeof(part) , "\n%s" , ComGeneral[i] );
        strcat( dialog , part , sizeof(dialog) );
    }
    printf( "[string check] dialog length %d ( size %d )" , strlen( dialog ) , sizeof(dialog) );
    // use this to check that the size of dialog is sufficient
   
    ShowPlayerDialog( playerid , 5 , DIALOG_STYLE_LIST , "Commands" , dialog , "Close" , "" );
    return 1;
}
The limit for one line in pawno ( ie the editor / compiler ) is lower than the limit on dialog size.
To make sure your dialog string is big enough, adjust the size of 'dialog' until it is at least 5 chars longer than the string length.
I will try it too. I was thinking to make it like this, but it's more confusing


__________________________________________________ ___________________

EDIT: Thanks both!
Also, Rachael if I want on click the first cmd, for example the first cmd is /kill, how can I do that on click , to SetPlayerHealth 0
Reply


Messages In This Thread
ShowPlayerDialog - by Kostas' - 12.10.2011, 08:38
Re: ShowPlayerDialog - by iJumbo - 12.10.2011, 08:47
Re: ShowPlayerDialog - by Rachael - 12.10.2011, 08:55
Re: ShowPlayerDialog - by Kostas' - 12.10.2011, 09:02

Forum Jump:


Users browsing this thread: 3 Guest(s)