Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Define script numbers at the top, to make them quickly changable.
- #Define NS_Cl_Input_Script 961
- #Define NS_Sv_Input_Script 962
- // Player Input (Client-Side): Detects input and informs the Server when it changes.
- Script NS_Cl_Input_Script Enter ClientSide
- {
- // Not needed or desired in TitleMaps.
- If (GameType() == GAME_TITLE_MAP) Terminate;
- // Which Player?
- Int ThisPlayer = PlayerNumber();
- // Cancel if somehow called by a non-Player.
- If ((ThisPlayer < 0) || (ThisPlayer >= 32)) Terminate;
- // For storing buttons.
- Int ThemButtons, ThemOldButtons;
- While (True)
- {
- // Here you should check whether the Player has left, and terminate.
- // For key detection in weapons/items.
- ThemButtons = GetPlayerInput(PlayerNumber(), INPUT_BUTTONS);
- ThemOldButtons = GetPlayerInput(PlayerNumber(), INPUT_OLDBUTTONS);
- // Attack
- If (ThemButtons & BT_ATTACK)
- {
- If (!(ThemOldButtons & BT_ATTACK)) ACS_ExecuteAlways (NS_Sv_Input_Script, 0, BT_ATTACK, 1);
- }
- Else
- {
- If (ThemOldButtons & BT_ATTACK) ACS_ExecuteAlways (NS_Sv_Input_Script, 0, BT_ATTACK, 0);
- }
- // Check other Inputs here.
- // This is required, Terran.
- Delay (1);
- }
- }
- // Player Input (Server-Side): Called by NS_Cl_Input_Script.
- Script NS_Sv_Input_Script (Int ThisButton, Int ThisValue)
- {
- // Cancel if somehow called by a non-Player.
- Int ThisPlayer = PlayerNumber();
- If ((ThisPlayer < 0) || (ThisPlayer >= 32)) Terminate;
- Switch (ThisButton)
- {
- Case BT_ATTACK:
- If (ThisValue)
- {
- // Give a flag item or set a property.
- }
- Else
- {
- // Remove the flag item.
- }
- Break;
- // Handle other controls here.
- }
- }
- /*
- The first script is handled clientside, where a 1-tic loop will not be laggy. As soon as an input change is detected, it calls the second script, which is server-side.
- Calls to the server script, and status changes associated with them, are only done when actually needed. This should, in theory, prevent lag.
- */
Advertisement
Add Comment
Please, Sign In to add comment