Help with OnDialogResponse -
LeXuZ - 23.11.2014
Hello, i've been working on an admin command, but i needed to use OnDialogResponse, but i don't really know which to use or how i would set it out, can someone please give me a example, thank you
Код:
ACMD:admincp(playerid, params[])
{
SPD(playerid, Admincp, DIALOG_STYLE_LIST, "Admin command panel", "Clearchat\nAdministrator commands\n","Select", "Close");
return 1;
}
this is the command i want to add in the admin command panel
Код:
ACMD:clearchat(playerid, params[])
{
if (pInfo[playerid][Adminlevel] < 1) return 0;
for(new i;i<100;i++)
SCMToAll(-1, " ");
return 1;
}
Re: Help with OnDialogResponse -
LeXuZ - 23.11.2014
Hmm, i've added this and it complies perfect,
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == Admincp)
{
if(response)
switch(listitem)
{
case 0:
{
if (pInfo[playerid][Adminlevel] < 1) return 0;
for(new i;i<100;i++)
SCMToAll(-1, " ");
return 1;
}
case 1:
{
new str[300], str1[1000];
if (pInfo[playerid][Adminlevel] >= 1)
{
format(str, sizeof(str), "{FF0000}Moderator commands\n");
strcat(str1, str);
format(str, sizeof(str), "/a - Admin Chat\n");
strcat(str1, str);
format(str, sizeof(str), "/spec - Spectate a player\n");
strcat(str1, str);
format(str, sizeof(str), "/go - Teleport to a player\n");
strcat(str1, str);
format(str, sizeof(str), "/get - Teleport a player to you\n\n");
strcat(str1, str);
}
if (pInfo[playerid][Adminlevel] >= 2)
{
format(str, sizeof(str), "Administrator commands\n");
strcat(str1, str);
format(str, sizeof(str), "/sethelper - set a player helper\n");
strcat(str1, str);
format(str, sizeof(str), "/vehicle - Give a player a vehicle\n");
strcat(str1, str);
format(str, sizeof(str), "/setname - Set a players name\n");
strcat(str1, str);
format(str, sizeof(str), "/repair - Repair vehicle\n");
strcat(str1, str);
format(str, sizeof(str), "/setpremium - set a player premium\n\n");
strcat(str1, str);
}
if (pInfo[playerid][Adminlevel] >= 3)
{
format(str, sizeof(str), "Lead administrator commands\n");
strcat(str1, str);
format(str, sizeof(str), "/setadmin - set a player admin\n");
strcat(str1, str);
format(str, sizeof(str), "/restart - restart the server\n\n");
strcat(str1, str);
}
if (pInfo[playerid][Adminlevel] >= 4)
{
format(str, sizeof(str), "LeXuZ & Jakwobs commands\n");
strcat(str1, str);
format(str, sizeof(str), "/what - what the fuck\n");
strcat(str1, str);
format(str, sizeof(str), "/die - kill \n");
strcat(str1, str);
}
ShowPlayerDialog(playerid, Admincmd, DIALOG_STYLE_MSGBOX, "Admin commands", str1 ,"close","");
}
}
}
}
return 1;
}
but when i am in game it does nothing, don't show the commands nor clear the chat, but it does pop up with the admincp dialog
Re: Help with OnDialogResponse -
UltraScripter - 23.11.2014
pawn Код:
ACMD:admincp(playerid, params[])
{
SPD(playerid, Admincp, DIALOG_STYLE_LIST, "Admin command panel", "Clearchat\nAdministrator commands\n","Select", "Close");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(response)
{
switch(dialogid == Admincp)
{
case 1:
{
switch(listitem)
{
case 0:
{
if (pInfo[playerid][Adminlevel] < 1) return 0;
for(new i;i<100;i++)
SCMToAll(-1, " ");
}
case 1:
{
// add more cods if u need more
}
}
}
}
}
return 1;
}
Re: Help with OnDialogResponse -
LeXuZ - 23.11.2014
Alright, i will test what you have posted, thanks for replying
Re: Help with OnDialogResponse -
UltraScripter - 23.11.2014
It Should Work Bro But Tell If It Dont Work
!.
Re: Help with OnDialogResponse -
LeXuZ - 23.11.2014
It didn't work, it still pops up with the admincp, but when i press clearchat it does nothing
Re: Help with OnDialogResponse -
UltraScripter - 23.11.2014
try to add this script to your gamemode
Re: Help with OnDialogResponse -
biker122 - 23.11.2014
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == Admincp)
{
if(response)
{
switch(listitem)
{
case 0:
{
if (pInfo[playerid][Adminlevel] == 0) return SendClientMessage(playerid, -1, "You are not authorized to use this command!");
for(new i = 0; i < 100; i++) SendClientMessageToAll(-1, "");
GameTextForAll("~g~Chat cleared!", 3000, 5);
}
case 1:
{
new str1[158];
if (pInfo[playerid][Adminlevel] == 1)
{
format(str1, sizeof str1, "{FF0000}Moderator commands\n/a - Admin Chat\n/spec - Spectate a player\n/get - Teleport a player to you\n\n");
}
else if (pInfo[playerid][Adminlevel] == 2)
{
format(str1, sizeof str1, "Administrator commands\n/sethelper - set a player helper\n/vehicle - Give a player a vehicle\n/setname - Set a players name\n \
/repair - Repair vehicle\n/setpremium - set a player premium\n\n");
}
else if (pInfo[playerid][Adminlevel] == 3)
{
format(str1, sizeof(str1), "Lead administrator commands\n/setadmin - set a player admin\n/restart - restart the server\n\n");
}
else if (pInfo[playerid][Adminlevel] == 4)
{
format(str1, sizeof(str1), "LeXuZ & Jakwobs commands\n/what - what the fuck\n/die - kill \n");
}
ShowPlayerDialog(playerid, Admincmd, DIALOG_STYLE_MSGBOX, "Admin commands", str1 ,"close","");
}
}
}
}
return 1;
}
Try this.
Re: Help with OnDialogResponse -
LeXuZ - 23.11.2014
None of these seem to be working, could there be a clash or something?
Re: Help with OnDialogResponse -
Mic_H - 23.11.2014
Make sure you are doing "return 0;" on other scripts..
Refer:
https://sampwiki.blast.hk/wiki/OnDialogResponse
PHP код:
public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[])
{
if(response)
{
switch(dialogid==Admincp)
{
case 1:
{
switch(listitem)
{
case 0:
{
if(pInfo[playerid][Adminlevel]<1) return 1; //Return 1 to stop furter checking
for(newi;i<100;i++)
SCMToAll(-1,"");
}
case 1:
{
//addmorecodsifuneedmore
}
}
}
}
}
return 0;//Return 0 in all other scripts, else it wont work..
//return 0 = It will continue to check other scripts.
}