Command Generator
A Guide For The Community

Command Generator is a helpful teleport command generator that all players can use in-game, rather than opening up your 'Debug'. It can be tricky if you run a server, and your users want different teleport commands, so why not let them do all the work. That way, everybody is happy, and you will keep the player coming back, which is ultimately a good thing.



Background Information:
I decided a long time ago to make a script that would allow newer scripters to create commands in-game. The easiest way to show how to do this was to write the commands inside a file, which could then be transferred to a script, becoming permanent. However, after reading my code a few days ago, I was once again thinking to myself that this really was a good idea. I fixed up the code, making it more efficient, as well as looking nicer, and then started to see the potential of this script.
I added in an invalid names checker, so that you can not have people re-writing your commands, and also added in a way to allow generated commands to be used immediately.

As most people know, I like helping people (such as my administration filterscript tutorial), and after a short discussion on IRC about it, I decided to comment my script, which aids the reader even further. All comments are in great depth, and can help the reader become better than ever.



What's New:
  • Script runs more efficiently.
  • Added a more friendly interface, and also a helpsection.
  • Command name changed to '/cgen'.
  • Added ability to immediately use generated commands if the server allows it.
  • Added inbuilt checker for existing commands with the same name. When a player generates a command with a name
    that has already been used, it will return an error message to the player.
  • Added inbuilt checker for invalid command names which is easily configurable by the server owner. When a player generates a command with a name that has been disabled, it will return an error message to the player.
  • Added greater indentation to the written file.
  • Added the ability to show a message to all connected players about how to use a generated command, as well as writing this to the file (if configured).



Commands:
1. '/cgen [command name]': Generate a command for the server owner.
2. '/[command name]': If enabled by the server, immediate command use is allowed. Read below for more information.
3. '/cgen help': See a series of information about Command Generator.



Usage: (READ THE 'readme.html' FILE INCLUDED WITH THE ZIPPED FOLDER)
1. Extract the contents of the folder to your server's directory.
2. Add 'Command_Generator' to your 'server.cfg' file under the line 'filterscripts'. EXAMPLE:
PAWN Code:
filterscripts Command_Generator
3. Go in-game and type /cgen (command name).
4. Open up your 'Generated_Commands.txt' file in your 'Scriptfiles' folder of your server's directory.
5. Copy the contents of the file (Right Click > Select All > Right Click > Copy) and then open up your Gamemode.pwn (or whatever your gamemode is called).
6. Scroll down to the line: "public OnPlayerCommandText(playerid,cmdtext[])" or "Script_OnPlayerCommandText(playerid, cmdtext[])" for YSI users.
7. Press 'Paste' under your existing commands.
8. Compile, and your done.



Customizing The Script:
Look for these lines just below the script heading:
PAWN Code:
#define PrintInConsole 1 
#define SaveCommands 1
#define SendAdminMessage 1
#define SendAnnounceMessage 1
#define SendTeleMessage 1
#define VehicleTele 1

Heres the breakdown on what each does:
1. PrintInConsole: If 1, A message will be displayed inside the server console (samp-server.exe) telling you the player's name, their IP address, and the command name that the player requested. If true, no message will be displayed in the server console.
2. SaveCommands: If 1, all commands will be able to be used immediately. They will still be saved to a file regardless of this define, but they will also be directly usable by players without the server owner having to interfere.
3. SendAdminMessage: If 1, a ClientMessage will be sent to all RCON Administrators that are logged in, telling them the player's name, player's id, and the command name that the player requested.If false, no message will be sent to online administrators.
4. SendAnnounceMessage: If 1, a ClientMessage will be sent to all connected players, telling them that
a player has just used a generated command, and that other players can do so as well. Also, the code to send a ClientMessage
to all players will be saved to the file. If false, no message will be sent to online players.
5. SendTeleMessage: If 1, a ClientMessage will be sent to the command user, telling them who made the command, and also how they themselves can generate a command.
6. VehicleTele: If 1, the generated command will include the necessary functions so that if a player is in a vehicle, they will teleport to the location in their vehicle. If false, the person will teleport to the location on foot, regardless of whether the person was in a vehicle prior to teleporting.

To change these, add false or true after each value according to what you wish to alter. EXAMPLE:
PAWN Code:
#define PrintInConsole 0 
#define SaveCommands 1
#define SendAdminMessage 0
#define SendAnnounceMessage 1
#define SendTeleMessage 0
#define VehicleTele 1



Example:
Generated commands will look like this, inside Generated_Commands.txt:
PAWN Code:
if(strcmp("/golf", cmdtext, true, 5) == 0) // Requested by player 'Cueball' (IP: 127.0.0.1) on the 18/5/2008. Time: 17:6:31
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SetPlayerInterior(playerid, 0);
LinkVehicleToInterior(GetPlayerVehicleID(playerid), 0);
SetVehiclePos(GetPlayerVehicleID(playerid), 1498.904541, 2773.460937, 10.391650);
SetVehicleZAngle(GetPlayerVehicleID(playerid), 180.945861);
return 1;
}
else
{
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, 1498.904541, 2773.460937, 10.391650);
SetPlayerFacingAngle(playerid, 180.945861);
return 1;
}
}

// ******************* Command Generator By ~Cueball~ ******************* \\





Download Links:



If you have any problems, please post them in this topic. With kind regards,
~Cueball~

0 komentarze:

Prześlij komentarz