Need Help 2
#1

What does This mean?

public OnPlayerClickPlayer(playerid, clickedplayerid, source)

and i want to make a dialog for weapons and i need help in it

i know how to make options but idk when a player click Rifles and choose a weapon he should get it?and when he selects a Weapon Pack he should Get All weapons in That Pack

Please help me by sending the cods which i should edit like this :
pawn Код:
/*------------------------------------------------------------------------------

                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                     ~                          ~
                     ~   '/command'  Menu.       ~
                     ~                          ~
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

######################################
~> Copyright © 2007 LuxeoN

~> Type - Filterscript [FS]

~> Version 1.0a (Tested and released)

~> Contact LuxeoN: (sa-mp forum)
######################################

Thanks to sa-mp team/forum for Everything they made!

~~~~@~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~@~~~~~
NB! This script can be found at sa-mp forum.
This script cant be sold.
Dont remove text ,that is written up here (credits).
Even if you edited it more than 50% ,dont remove my credits.
You can just add:
edited by YourName.

,Thanks.
------------------------------------------------------------------------------*/


/* ~includes  */
#include <a_samp>
#include <float>

/* ~defines  */
#define red 0xFF0000AA
#define yellow 0xFFFF00AA

/* ~Menu start!:     [menu parts]  */

new Menu:Menu;
new Menu:submenu1;
new Menu:submenu2;
new Menu:submenu3;
new Menu:submenu4;
new Menu:submenu5;

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print("   [FS] '/command' Menu by LuxeoN.    ");
    print("--------------------------------------\n");
    Menu = CreateMenu("MenuName",1,20,120,150,40); //main  menu start
    AddMenuItem(Menu,0,"Name1");     // 1 <~ submenu numbers
    AddMenuItem(Menu,0,"Name2");   // 2
    AddMenuItem(Menu,0,"Name3");  // 3
    AddMenuItem(Menu,0,"Name4");      // 4
    AddMenuItem(Menu,0,"Name5");    // 5
    submenu1 = CreateMenu("Name1",1,20,120,150,40); // << 1
    AddMenuItem(submenu1,0,"text1");
    AddMenuItem(submenu1,0,"text2");
    AddMenuItem(submenu1,0,"Back");  //                         <<<<<[ NB! Dont forget about 'Back' option! ,lol.
    submenu2 = CreateMenu("Name2",1,20,120,150,40); // << 2                  otherwise it will just close the menu ! ]
    AddMenuItem(submenu2,0,"text1");
    AddMenuItem(submenu2,0,"text2");
    AddMenuItem(submenu2,0,"text3");
    AddMenuItem(submenu2,0,"Back");
    submenu3 = CreateMenu("Name3",1,20,120,150,40); // << 3
    AddMenuItem(submenu3,0,"Text1");
    AddMenuItem(submenu3,0,"Text2");
    AddMenuItem(submenu3,0,"Text3");
    AddMenuItem(submenu3,0,"Back");
    submenu4 = CreateMenu("Name4",1,20,120,150,40); // << 4
    AddMenuItem(submenu4,0,"Text1");
    AddMenuItem(submenu4,0,"Back");
    submenu5 = CreateMenu("Name5",1,20,120,150,40); //<< 5
    AddMenuItem(submenu5,0,"Text1");
    AddMenuItem(submenu5,0,"Back");   // ...[ if you need more Things in submenu ,then do AddMenuItems ,
                                      // then  edit it in 'Case X' in 'OnPlayerSelectedMenuRow(playerid, row)' . ]...
    return 1;
}

public OnPlayerCommandText(playerid,cmdtext[])
{
    new cmd[256];
    new idx;
    cmd = strtok(cmdtext, idx);

    if(strcmp(cmd, "/command", true) == 0) // Menu opening command ^^   (change it. )
    {

            TogglePlayerControllable(playerid, false);//<~player will not be able to move when menu will be opened. I recommend to leave it!
            ShowMenuForPlayer(Menu, playerid); // anyways if you will remove it ,then remove it from 'OnPlayerExitedMenu(playerid)' to !
            return 1;
    }
    return 0;
}

public OnFilterScriptExit()
{
    DestroyMenu(Menu:Menu); //main    // numbers of submenus:
    DestroyMenu(Menu:submenu1); //1
    DestroyMenu(Menu:submenu2); //2
    DestroyMenu(Menu:submenu3); //3
    DestroyMenu(Menu:submenu4); //4
    DestroyMenu(Menu:submenu5); //5
    return 1;
}

strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}

public OnPlayerSelectedMenuRow(playerid, row)  // menu optiones:
{
    new Menu:Current = GetPlayerMenu(playerid); // Main Menu optiones :
    if(Current == Menu) {
    switch(row){
        case 0: //  NB! everything start from 'Case 0' ,not 'case 1'   !!!!
            if(IsPlayerConnected(playerid))
            {
                ShowMenuForPlayer(submenu1, playerid); // 'ShowMenuForPlayer' = opens that menu.
            }
        case 1:
            if(IsPlayerConnected(playerid))
            {
                ShowMenuForPlayer(submenu2, playerid);
            }
        case 2:
            if(IsPlayerConnected(playerid))
            {
                ShowMenuForPlayer(submenu3, playerid);
            }
        case 3:
            if(IsPlayerConnected(playerid))
            {
                ShowMenuForPlayer(submenu4, playerid);
            }
        case 4:
            if(IsPlayerConnected(playerid))
            {
                ShowMenuForPlayer(submenu5, playerid);
            }

    }
    }
    if(Current == submenu1) { // submenu1 optiones:
    switch(row){
        case 0:  // and again all start from 'Case 0 ' !
            if(GetPlayerMoney(playerid) >= 0) // ...[put here price if you want your menu to cost something.
            {                                         // (useful if you will remake this into weapon menu)]...
                SendClientMessage(playerid,yellow,"~~~~~Text1:~~~~~");
                SendClientMessage(playerid,yellow,"line1");
                SendClientMessage(playerid,yellow,"line2");
                SendClientMessage(playerid,yellow,"line3");
                ShowMenuForPlayer(Menu, playerid);
            }
            else
            {
                SendClientMessage(playerid,red,"Not enough money!"); //if you will add  line 169 with price ,then this will start working !
                ShowMenuForPlayer(Menu, playerid);
            }
        case 1:
            if(GetPlayerMoney(playerid) >= 0)
            {
                SendClientMessage(playerid,yellow,"~~~~~Text2:~~~~~");
                SendClientMessage(playerid,yellow,"line1");
                SendClientMessage(playerid,yellow,"line2");
                SendClientMessage(playerid,yellow,"line3");
                ShowMenuForPlayer(Menu, playerid);
            }
            else
            {
                SendClientMessage(playerid,red,"Not enough money!");
                ShowMenuForPlayer(Menu, playerid);
            }

        case 2:ShowMenuForPlayer(Menu, playerid); // <~ Thats 'back' option ;)
    }
    }
    if(Current == submenu2) { //submenu2 optiones:
    switch(row){
        case 0:
            if(GetPlayerMoney(playerid) >= 0)
            {
                SendClientMessage(playerid,yellow,"~~~~~Text1:~~~~~");
                 SendClientMessage(playerid,yellow,"line1");
                SendClientMessage(playerid,yellow,"line2");
                SendClientMessage(playerid,yellow,"line3");
                ShowMenuForPlayer(Menu, playerid);
            }
            else
            {
                SendClientMessage(playerid,red,"Not enough money!");
                ShowMenuForPlayer(Menu, playerid);
            }
        case 1:
            if(GetPlayerMoney(playerid) >= 0)
            {
                SendClientMessage(playerid,yellow,"~~~~~text2:~~~~~");
                SendClientMessage(playerid,yellow,"line1");
                SendClientMessage(playerid,yellow,"line2");
                SendClientMessage(playerid,yellow,"line3");
                ShowMenuForPlayer(Menu, playerid);
            }
            else
            {
                SendClientMessage(playerid,red,"Not enough money!");
                ShowMenuForPlayer(Menu, playerid);
            }
         case 2:
            if(GetPlayerMoney(playerid) >= 0)
            {
                SendClientMessage(playerid,yellow,"~~~~~text3:~~~~~");
                SendClientMessage(playerid,yellow,"line1");
                SendClientMessage(playerid,yellow,"line2");
                SendClientMessage(playerid,yellow,"line3");
                ShowMenuForPlayer(Menu, playerid);
            }
            else
            {
                SendClientMessage(playerid,red,"Not enough money!");
                ShowMenuForPlayer(Menu, playerid);
            }

        case 3:ShowMenuForPlayer(Menu, playerid);
    }
    }
    if(Current == submenu3) { // submenu3 optiones:
    switch(row){
        case 0:
            if(GetPlayerMoney(playerid) >= 0)
            {
                SendClientMessage(playerid,yellow,"~~~~~text1:~~~~~");
                SendClientMessage(playerid,yellow,"line1");
                SendClientMessage(playerid,yellow,"line2");
                SendClientMessage(playerid,yellow,"line3");
                ShowMenuForPlayer(Menu, playerid);
            }
            else
            {
                SendClientMessage(playerid,red,"Not enough money!");
                ShowMenuForPlayer(Menu, playerid);
            }
        case 1:
            if(GetPlayerMoney(playerid) >= 0)
            {
                SendClientMessage(playerid,yellow,"~~~~~Text2:~~~~~");
                SendClientMessage(playerid,yellow,"line1");
                SendClientMessage(playerid,yellow,"line2");
                SendClientMessage(playerid,yellow,"line3");
                ShowMenuForPlayer(Menu, playerid);
            }
            else
            {
                SendClientMessage(playerid,red,"Not enough money!");
                ShowMenuForPlayer(Menu, playerid);
            }

        case 2:ShowMenuForPlayer(Menu, playerid);
    }
    }
    if(Current == submenu4) { // submenu4 optiones:
    switch(row){
        case 0:
            if(GetPlayerMoney(playerid) >= 0)
            {
                SendClientMessage(playerid,yellow,"~~~~~Text1:~~~~~");
                SendClientMessage(playerid,yellow,"line1");
                SendClientMessage(playerid,yellow,"line2");
                SendClientMessage(playerid,yellow,"line3");
                ShowMenuForPlayer(Menu, playerid);
            }
            else
            {
                SendClientMessage(playerid,red,"Not enough money!");
                ShowMenuForPlayer(Menu, playerid);
            }

        case 1:ShowMenuForPlayer(Menu, playerid);
    }
    }
    if(Current == submenu5) { //submenu5 optiones:
    switch(row){
        case 0:
            if(GetPlayerMoney(playerid) >= 0)
            {
                SendClientMessage(playerid,yellow,"~~~~~text1:~~~~~");
                SendClientMessage(playerid,yellow,"line1");
                SendClientMessage(playerid,yellow,"line2");
                SendClientMessage(playerid,yellow,"line3");
                ShowMenuForPlayer(Menu, playerid);
            }
            else
            {
                SendClientMessage(playerid,red,"Not enough money!");
                ShowMenuForPlayer(Menu, playerid);
            }

        case 1:ShowMenuForPlayer(Menu, playerid);
    }
    }
 // you can add more submenus here ,after adding them in : 'OnFilterScriptInit()' ; 'OnFilterScriptExit()' and finally here.
}

public OnPlayerExitedMenu(playerid)
{
    TogglePlayerControllable(playerid, true); // after menu exiting Player will be controllable back!
}

public OnPlayerSpawn(playerid)
{
    SendClientMessage(playerid,red,"Be sure to check out our new generation '/command' menu !"); //this will send Message at player spawn.
}



I have Corrected the errors

Web: https://sampforum.blast.hk/showthread.php?tid=389763


Originally Posted by tyler12
PHP код:
public OnPlayerClickMap(playeridFloat:fXFloat:fYFloat:fZ

    if(
IsPlayerAdmin(playerid)) 
    { 
        new 
string[124
        
SetPlayerPos(playerid,fX,fY,fZ); 
        
format(string,sizeof(string,"Teleported to %f %f %f",fX,fY,fZ); 
        
SendClientMessage(playerid,-1,string); 
    } 
    return 
1

It's when a player clicks the map. The code above if the player is a RCON admin, he will be teleported to that position and sent a message of the co-ords.


Two errors

I corrected it

PHP код:
public OnPlayerClickMap(playeridFloat:fXFloat:fYFloat:fZ

    if(
IsPlayerAdmin(playerid)) 
    { 
        new 
string[124]; 
        
SetPlayerPos(playerid,fX,fY,fZ); 
        
format(string,sizeof(string),"Teleported to %f %f %f",fX,fY,fZ); 
        
SendClientMessage(playerid,-1,string); 
    } 
    return 
1

and can anyone tell me how many %(variable) are there and what do they do?
Reply
#2

OnPlayerClickPlayer detects when you double click on a player's name on the player list (TAB). To detect dialog pressing, you need to do something like this:

pawn Код:
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Weapons", "Rifle\nDeagle", "Purchase", "Close");

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case 1:
        {
            switch(listitem)
            {
                case 0:
                {
                    GivePlayerWeapon(playerid, 33);
                    SendClientMessage(playerid, -1, "You have purchased a rifle.");
                }

                case 1:
                {
                    GivePlayerWeapon(playerid, 24);
                    SendClientMessage(playerid, -1, "You have purchased a deagle.");
                }
            }
        }
    }

    return 0;
}
%d or %i - integers in format
%f - floats in format
%s - strings in format

Those are the ones you'll use the most.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)