Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- using Samp.API;
- using Samp.Scripts;
- using Samp.Client;
- namespace testscript
- {
- class test : ScriptBase
- {
- public override void OnLoad() // When the script loads
- {
- /* Add Event Handlers In Here*/
- Player.OnPlayerCommandText += new EventHandler<Player.OnPlayerCommandTextEventArgs>(Player_OnPlayerCommandText); // Adding the OnPlayerCommandText Event Handler
- }
- public override void OnUnload() // When the script unloads
- {
- /* Deconstruct Event Handlers In Here [Must]*/
- Player.OnPlayerCommandText -= new EventHandler<Player.OnPlayerCommandTextEventArgs>(Player_OnPlayerCommandText); // Removing the OnPlayerCommandText Event Handler
- }
- private void Player_OnPlayerCommandText(object sender, Player.OnPlayerCommandTextEventArgs e) // Declaring the function which will handle OnPlayerCommandText Event
- {
- string[] cmd = e.text.Split(' '); //Declaring the string array which will split the command, the player wrote on console into words
- if (String.Compare(cmd[0], "/test") == 0) // Comparing the if the first word of the command is /test or not
- {
- int playerid = e.player.ID; // Get the player id who wrote the message
- //If so then it will trigger everything in here
- NativeFunctionRequestor.RequestFunction("SendClientMessage", playerid, -1, @"I love {00FF00} C#!"); // Requesting the function which is SendClientMessage with it's specific parameters
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment