Making a command to display command. -
TheDominator - 22.02.2012
I am very new to all of the PAWN scripting so yes I am a big noob. Now I have seen that on some servers there is a command like /cmds or /commands that will show all of the servers commands. I was wondering how I would go about making such a script.
I have a few commands that I would like to add to it like: /help /heal /kill and a few more eventually.
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/help", cmdtext, true, 10) == 0)
{
SendClientMessage(playerid, COLOR_1, "Welcome to my server Drifting Legends, I hope you enjoy your stay.");
SendClientMessage(playerid, COLOR, "If you require any assistance then don't hesitate to ask our administrators.");
return 1;
}
if (strcmp("/heal", cmdtext, true, 10) == 0)
{
SetPlayerHealth(playerid, 100);
SendClientMessage(playerid, COLOR, "Your health has been successfully restored.");
return 1;
}
if (strcmp("/kill", cmdtext, true, 10) == 0)
{
SetPlayerHealth(playerid, 0);
return 1;
}
return 0;
}
I know I am not using zcmd or anything like that but I want to learn everything the easy way as I am a beginner.
Any assistance would be greatly appreciated and would earn you +Reputation for your account.
Re: Making a command to display command. -
ttloko2 - 22.02.2012
Its good for you to use sscanf and zcmd, they will organize better your command, you just gotta search for some tutorials, now about the /commands you can either show a menu or a message:
Message:
pawn Код:
if(strcmp("/commands", cmdtext, true, 10) == 0)
{
SendClientMessage(playerid, COLOR_BLUE, "-----Server Commands-----");
SendClientMessage(playerid, COLOR_BLUE, "/heal , /help, /kill");
return 1;
}
Dialog(Menu)
pawn Код:
if(strcmp("/commands", cmdtext, true, 10) == 0)
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Commands:", "/heal, /kill, /heal", "Ok", "");
return 1;
}
its good to define some colors to use later
put this on top of your script:
pawn Код:
#define COLOR_BLUE 0x0000FFFF
Hope i helped
Re: Making a command to display command. -
TheDominator - 22.02.2012
Mate thanks a lot for your help and quick response. I will +Rep your profile after I finish this post. Glad to know there are people like you around the forums. Thanks again for the help
Re: Making a command to display command. -
sniperwars - 09.03.2012
Or you can do it this way.
pawn Код:
if(strcmp, cmdtext, "/commands", true, 10) == 0)
{
new sz_msg [ 900 ];
strcat( sz_msg, "/heal /help /kill\r\n");
ShowPlayerDialog(playerid,1337,"DIALOG_STYLE_MSGBOX, "Server Commands", sz_msg, "Close","");
return 1;
}
I guess you don't need that now obviously because I'm scripting for you.
Re: Making a command to display command. -
rangerxxll - 10.03.2012
Even easier. Since you're new to pawn, I reckon you use Zcmd. It's a very fast, and simple command processor.
https://sampforum.blast.hk/showthread.php?tid=91354
Also, if you'd like a few scripting lessons feel free to leave me a PM.
Kind Regards.