SA-MP Forums Archive
Option in dialogue to run cmd? [+rep for asnwer] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Option in dialogue to run cmd? [+rep for asnwer] (/showthread.php?tid=335117)



Option in dialogue to run cmd? [+rep for asnwer] - alexharvey52 - 17.04.2012

Is there anyway to get it so when I click an option in my dialogue it will run my /duty cmd?

Here is my /duty cmd:

pawn Код:
if(strcmp(cmd, "/duty", true) == 0)
{
    if(IsPlayerConnected(playerid)) {
        GetPlayerName(playerid, sendername, sizeof(sendername));
        GiveNameSpace(sendername);
        if(PlayerInfo[playerid][pMaskUse] == 1) { format(sendername, sizeof(sendername), "[Mask_%d_38]", RandMask[playerid]); }
        if(PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pMember] == 14) {
            if (PlayerToPoint(3, playerid,255.3,77.4,1003.6) || PlayerToPoint(3,playerid,327.2265,307.9479,999.1484) || PlayerToPoint(3,playerid,233.0675,123.5211,1003.2188)) {
                if(OnDuty[playerid]==0) {
                    format(string, sizeof(string), "* Officer %s took a Badge and a Gun from there locker.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    GivePlayerWeaponEx(playerid, 24, 250);
                    GivePlayerWeaponEx(playerid, 25, 300);
                    GivePlayerWeaponEx(playerid, 3, 0);
                    GivePlayerWeaponEx(playerid, 41, 1000);
                    GivePlayerWeaponEx(playerid, 29, 500);
                    SetPlayerArmourEx(playerid, 100);
                    SetPlayerHealthEx(playerid, 100);
                    SetPlayerColor(playerid,TEAM_BLUE_COLOR);
                    OnDuty[playerid] = 1;
                }
                else if(OnDuty[playerid]==1) {
                    format(string, sizeof(string), "* Officer %s places there Badge and Gun in there locker.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    GivePlayerWeaponEx(playerid, 24, 150);
                    GivePlayerWeaponEx(playerid, 5, 0);
                    SetPlayerColor(playerid,TEAM_HIT_COLOR);
                    OnDuty[playerid] = 0;
                }
            }
            else {
                SendClientMessage(playerid, COLOR_GRAD2, "   You are not in a locker room !");
                return 1;
            }
        }
        else if(PlayerInfo[playerid][pMember] == 2) {
            if (PlayerToPoint(3, playerid,196.9520,168.6917,1003.0234) || PlayerToPoint(3,playerid,196.9749,169.9257,1003.0234)) {
                if(OnDuty[playerid]==0) {
                    format(string, sizeof(string), "* Agent %s took a Badge and a Gun from there locker.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    GivePlayerWeaponEx(playerid, 43, 100);
                    GivePlayerWeaponEx(playerid, 24, 100);
//                  GivePlayerWeaponEx(playerid, 3, 1);
                    SetPlayerArmourEx(playerid, 100);
                    SetPlayerHealthEx(playerid, 100);
                    OnDuty[playerid] = 1;
                }
                else if(OnDuty[playerid]==1) {
                    format(string, sizeof(string), "* Agent %s places there Badge and Gun in there locker.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    GivePlayerWeaponEx(playerid, 24, 150);
                    GivePlayerWeaponEx(playerid, 5, 0);
                    OnDuty[playerid] = 0;
                }
            }
            else {
                SendClientMessage(playerid, COLOR_GRAD2, "   You are not in a locker room !");
                return 1;
            }
        }
                else if(PlayerInfo[playerid][pMember] == 15) {
            if (PlayerToPoint(3, playerid,2743.7537,-2453.8313,13.8623,88.8243) || PlayerToPoint(3,playerid,2743.7537,-2453.8313,13.8623,88.8243)) {
                if(OnDuty[playerid]==0) {
                    format(string, sizeof(string), "* Soldier %s took a Badge and a Gun from there locker.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    GivePlayerWeaponEx(playerid, 24, 100);
                    GivePlayerWeaponEx(playerid, 31, 400);
//                  GivePlayerWeaponEx(playerid, 3, 1);
                    SetPlayerArmourEx(playerid, 100);
                    SetPlayerHealthEx(playerid, 100);
                    SetPlayerColor(playerid, GREEN);
                    OnDuty[playerid] = 1;
                }
                else if(OnDuty[playerid]==1) {
                    format(string, sizeof(string), "* Soldier %s places there Badge and Gun in there locker.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    GivePlayerWeaponEx(playerid, 24, 150);
                    GivePlayerWeaponEx(playerid, 5, 0);
                    OnDuty[playerid] = 0;
                }
            }
            else {
                SendClientMessage(playerid, COLOR_GRAD2, "   You are not in a locker room !");
                return 1;
            }
        }
        else if(PlayerInfo[playerid][pMember] == 3) {
            if (PlayerToPoint(3, playerid,255.3,77.4,1003.6) || PlayerToPoint(3,playerid,354.3689,173.8600,1008.3828)) {
                if(OnDuty[playerid]==0) {
                    format(string, sizeof(string), "* Bodyguard %s took some guns from the weapons locker.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    GivePlayerWeaponEx(playerid, 24, 250);
                    SetPlayerArmourEx(playerid, 100);
                    SetPlayerHealthEx(playerid, 100);
                    //SetPlayerColor(playerid,COLOR_LIGHTPURPLE);
                    OnDuty[playerid] = 1;
                }
                else if(OnDuty[playerid]==1) {
                    format(string, sizeof(string), "* Bodyguard %s places there guns in the weapons locker.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    GivePlayerWeaponEx(playerid, 24, 150);
                    GivePlayerWeaponEx(playerid, 5, 0);
                    //SetPlayerColor(playerid,TEAM_HIT_COLOR);
                    OnDuty[playerid] = 0;
                }
            }
            else {
                SendClientMessage(playerid, COLOR_GRAD2, "   You are not at the locker!");
                return 1;
            }
        }
        else if(PlayerInfo[playerid][pMember] == 4) {
            if (PlayerToPoint(100.0, playerid,-3451.3801,475.9214,58.0620)) {
                if(OnDuty[playerid] == 1) {
                    SendClientMessage(playerid, COLOR_GRAD3, "* You are now Off Duty from your Medic Job and will not receive calls anymore.");
                    OnDuty[playerid] = 0;
                }
                else {
                    SendClientMessage(playerid, COLOR_GRAD3, "* You are now On Duty with your Medic Job and will receive calls from people in need.");
                    GetPlayerName(playerid,sendername,sizeof(sendername));
                    GiveNameSpace(sendername);
                    format(string, sizeof(string), "[Advert] Paramedic %s is On Duty, /cell 911.", sendername);
                    BroadCast(COLOR_ALLDEPT,string);
                    OnDuty[playerid] = 1;
                }
            }
            else {
                SendClientMessage(playerid, COLOR_GRAD2, "   You are not at the hospital!");
                return 1;
            }
        }
        else if(PlayerInfo[playerid][pMember] == 7) {
            if(idcar >= 61 && idcar <= 70) {
                if(TaxiDuty[playerid] == 1) {
                    SendClientMessage(playerid, COLOR_GRAD3, "* You are now Off Duty from your Taxi Job.");
                    TaxiDuty[playerid] = 0;
                }
                else {
                    GetPlayerName(playerid,sendername,sizeof(sendername));
                    GiveNameSpace(sendername);
                    format(string, sizeof(string), "Taxi Driver %s is On Duty, /cell 444.", sendername);
                    BroadCast(0xFF942896,string);
                    TaxiDuty[playerid] = 1;
                }
            }
            else {
                SendClientMessage(playerid, COLOR_GRAD2, "   You are not inside a Taxi!");
                return 1;
            }
        }
    }
    return 1;
}



Re: Option in dialogue to run cmd? [+rep for asnwer] - Cjgogo - 17.04.2012

When player selects dialog's option:
pawn Код:
return cmd_duty;



Re: Option in dialogue to run cmd? [+rep for asnwer] - alexharvey52 - 17.04.2012

Quote:
Originally Posted by Cjgogo
Посмотреть сообщение
When player selects dialog's option:
pawn Код:
return cmd_duty;
error 017: undefined symbol "cmd_duty"


Re: Option in dialogue to run cmd? [+rep for asnwer] - Cjgogo - 17.04.2012

Oh sorry then,it means it works only for ZCMD,sorry .


Re: Option in dialogue to run cmd? [+rep for asnwer] - PrawkC - 17.04.2012

Quote:
Originally Posted by Cjgogo
Посмотреть сообщение
When player selects dialog's option:
pawn Код:
return cmd_duty;
You're an idiot.

You're going to have to grab the main part of the code, IE not include the online checking, and place it inside the check for clicking that dialog option.


Re: Option in dialogue to run cmd? [+rep for asnwer] - Cjgogo - 17.04.2012

Quote:
Originally Posted by PrawkC
Посмотреть сообщение
You're an idiot.

You're going to have to grab the main part of the code, IE not include the online checking, and place it inside the check for clicking that dialog option.
Works for ZCMD.


Re: Option in dialogue to run cmd? [+rep for asnwer] - PrawkC - 17.04.2012

Quote:
Originally Posted by Cjgogo
Посмотреть сообщение
You're a bigger idiot,it works for ZCMD,what's ZCMD,well,there's something new outta there called WikiPedia&******,check it idiot.
I know it works with ZCMD, But does his code use ZCMD? No, thus you're an idiot for not reading his post and seeing that he is not using ZCMD.


Re: Option in dialogue to run cmd? [+rep for asnwer] - alexharvey52 - 17.04.2012

hmm, anybody else got any ideas?


Re: Option in dialogue to run cmd? [+rep for asnwer] - fordawinzz - 17.04.2012

cjgogo: that won't work for zcmd, that's how it works:
pawn Код:
return cmd_duty(playerid, params);
and for you:
pawn Код:
OnPlayerCommandText(playerid, "/duty");
try it.


Re: Option in dialogue to run cmd? [+rep for asnwer] - Marco_Valentine - 17.04.2012

Код:
forward Duty(playerid);
public Duty(playerid)
	{
	if(IsPlayerConnected(playerid)) {
        GetPlayerName(playerid, sendername, sizeof(sendername));
        GiveNameSpace(sendername);
        if(PlayerInfo[playerid][pMaskUse] == 1) { format(sendername, sizeof(sendername), "[Mask_%d_38]", RandMask[playerid]); }
        if(PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pMember] == 14) {
            if (PlayerToPoint(3, playerid,255.3,77.4,1003.6) || PlayerToPoint(3,playerid,327.2265,307.9479,999.1484) || PlayerToPoint(3,playerid,233.0675,123.5211,1003.2188)) {
                if(OnDuty[playerid]==0) {
                    format(string, sizeof(string), "* Officer %s took a Badge and a Gun from there locker.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    GivePlayerWeaponEx(playerid, 24, 250);
                    GivePlayerWeaponEx(playerid, 25, 300);
                    GivePlayerWeaponEx(playerid, 3, 0);
                    GivePlayerWeaponEx(playerid, 41, 1000);
                    GivePlayerWeaponEx(playerid, 29, 500);
                    SetPlayerArmourEx(playerid, 100);
                    SetPlayerHealthEx(playerid, 100);
                    SetPlayerColor(playerid,TEAM_BLUE_COLOR);
                    OnDuty[playerid] = 1;
                }
                else if(OnDuty[playerid]==1) {
                    format(string, sizeof(string), "* Officer %s places there Badge and Gun in there locker.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    GivePlayerWeaponEx(playerid, 24, 150);
                    GivePlayerWeaponEx(playerid, 5, 0);
                    SetPlayerColor(playerid,TEAM_HIT_COLOR);
                    OnDuty[playerid] = 0;
                }
            }
            else {
                SendClientMessage(playerid, COLOR_GRAD2, "   You are not in a locker room !");
                return 1;
            }
        }
        else if(PlayerInfo[playerid][pMember] == 2) {
            if (PlayerToPoint(3, playerid,196.9520,168.6917,1003.0234) || PlayerToPoint(3,playerid,196.9749,169.9257,1003.0234)) {
                if(OnDuty[playerid]==0) {
                    format(string, sizeof(string), "* Agent %s took a Badge and a Gun from there locker.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    GivePlayerWeaponEx(playerid, 43, 100);
                    GivePlayerWeaponEx(playerid, 24, 100);
//                  GivePlayerWeaponEx(playerid, 3, 1);
                    SetPlayerArmourEx(playerid, 100);
                    SetPlayerHealthEx(playerid, 100);
                    OnDuty[playerid] = 1;
                }
                else if(OnDuty[playerid]==1) {
                    format(string, sizeof(string), "* Agent %s places there Badge and Gun in there locker.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    GivePlayerWeaponEx(playerid, 24, 150);
                    GivePlayerWeaponEx(playerid, 5, 0);
                    OnDuty[playerid] = 0;
                }
            }
            else {
                SendClientMessage(playerid, COLOR_GRAD2, "   You are not in a locker room !");
                return 1;
            }
        }
                else if(PlayerInfo[playerid][pMember] == 15) {
            if (PlayerToPoint(3, playerid,2743.7537,-2453.8313,13.8623,88.8243) || PlayerToPoint(3,playerid,2743.7537,-2453.8313,13.8623,88.8243)) {
                if(OnDuty[playerid]==0) {
                    format(string, sizeof(string), "* Soldier %s took a Badge and a Gun from there locker.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    GivePlayerWeaponEx(playerid, 24, 100);
                    GivePlayerWeaponEx(playerid, 31, 400);
//                  GivePlayerWeaponEx(playerid, 3, 1);
                    SetPlayerArmourEx(playerid, 100);
                    SetPlayerHealthEx(playerid, 100);
                    SetPlayerColor(playerid, GREEN);
                    OnDuty[playerid] = 1;
                }
                else if(OnDuty[playerid]==1) {
                    format(string, sizeof(string), "* Soldier %s places there Badge and Gun in there locker.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    GivePlayerWeaponEx(playerid, 24, 150);
                    GivePlayerWeaponEx(playerid, 5, 0);
                    OnDuty[playerid] = 0;
                }
            }
            else {
                SendClientMessage(playerid, COLOR_GRAD2, "   You are not in a locker room !");
                return 1;
            }
        }
        else if(PlayerInfo[playerid][pMember] == 3) {
            if (PlayerToPoint(3, playerid,255.3,77.4,1003.6) || PlayerToPoint(3,playerid,354.3689,173.8600,1008.3828)) {
                if(OnDuty[playerid]==0) {
                    format(string, sizeof(string), "* Bodyguard %s took some guns from the weapons locker.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    GivePlayerWeaponEx(playerid, 24, 250);
                    SetPlayerArmourEx(playerid, 100);
                    SetPlayerHealthEx(playerid, 100);
                    //SetPlayerColor(playerid,COLOR_LIGHTPURPLE);
                    OnDuty[playerid] = 1;
                }
                else if(OnDuty[playerid]==1) {
                    format(string, sizeof(string), "* Bodyguard %s places there guns in the weapons locker.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    GivePlayerWeaponEx(playerid, 24, 150);
                    GivePlayerWeaponEx(playerid, 5, 0);
                    //SetPlayerColor(playerid,TEAM_HIT_COLOR);
                    OnDuty[playerid] = 0;
                }
            }
            else {
                SendClientMessage(playerid, COLOR_GRAD2, "   You are not at the locker!");
                return 1;
            }
        }
        else if(PlayerInfo[playerid][pMember] == 4) {
            if (PlayerToPoint(100.0, playerid,-3451.3801,475.9214,58.0620)) {
                if(OnDuty[playerid] == 1) {
                    SendClientMessage(playerid, COLOR_GRAD3, "* You are now Off Duty from your Medic Job and will not receive calls anymore.");
                    OnDuty[playerid] = 0;
                }
                else {
                    SendClientMessage(playerid, COLOR_GRAD3, "* You are now On Duty with your Medic Job and will receive calls from people in need.");
                    GetPlayerName(playerid,sendername,sizeof(sendername));
                    GiveNameSpace(sendername);
                    format(string, sizeof(string), "[Advert] Paramedic %s is On Duty, /cell 911.", sendername);
                    BroadCast(COLOR_ALLDEPT,string);
                    OnDuty[playerid] = 1;
                }
            }
            else {
                SendClientMessage(playerid, COLOR_GRAD2, "   You are not at the hospital!");
                return 1;
            }
        }
        else if(PlayerInfo[playerid][pMember] == 7) {
            if(idcar >= 61 && idcar <= 70) {
                if(TaxiDuty[playerid] == 1) {
                    SendClientMessage(playerid, COLOR_GRAD3, "* You are now Off Duty from your Taxi Job.");
                    TaxiDuty[playerid] = 0;
                }
                else {
                    GetPlayerName(playerid,sendername,sizeof(sendername));
                    GiveNameSpace(sendername);
                    format(string, sizeof(string), "Taxi Driver %s is On Duty, /cell 444.", sendername);
                    BroadCast(0xFF942896,string);
                    TaxiDuty[playerid] = 1;
                }
            }
            else {
                SendClientMessage(playerid, COLOR_GRAD2, "   You are not inside a Taxi!");
                return 1;
            }
        }
    }
return 1;
}

OnPlayerCommandText(playerid)
{
if(strcmp(cmd, "/duty", true) == 0)
	{
		Duty(playerid);
	}
return 1;
}
On your dialog response just use
Код:
Duty(playerid);
Hope i helped