player2_dz

Untitled

Jan 18th, 2015
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.60 KB | None | 0 0
  1.     /*---------------------------------------------------------------------------
  2.     Anti-Wall-Crawl by Player2
  3.  
  4.     Description:
  5.         Prevents Exploitave use of smk prone animation to crawl under walls
  6.     ---------------------------------------------------------------------------*/
  7.     player addEventHandler ["AnimChanged", {
  8.         private ["_isSmkProne","_ogPos","_nearObjects"]; //privatise variables in memory to prevent error...
  9.         _isSmkProne = false; _ogPos = []; _nearObjects = []; //create variables we will use later as empty to prevent error...
  10.         _isSmkProne = [(_this select 1),"smk_urbanprone"] call KRON_strInStr; //check if anim is an urbanprone anim, players current anim = (_this select 1)
  11.         //if player is in urban prone anim, exit with the below code
  12.         if (_isSmkProne) exitWith {
  13.             _ogPos = position (_this select 0); //get player position at time of entering urbanprone anim and store it as ogPos (original position)
  14.             _nearObjects = nearestObjects [_ogPos, ["All"], 2.5]; //check how many objects are near the player
  15.             //if player is near any objects set them prone with a message and exit early
  16.             if (count _nearObjects > 1) exitWith { player switchMove "amovppnemstpsraswrfldnon"; systemChat("[ZombZ] Anti-Wall-Crawl: You cannot use this stance near objects."); };
  17.             //open a new thread if it didnt just exit, give the new thread the ogPos and player object ((_this select 0)) as input
  18.             0 = [_ogPos,(_this select 0)] spawn {
  19.                 private["_ogPos","_isSmkProne","_newPos","_newAnim","_plyr"]; //privatise variables in memory for new thread to prevent error...
  20.                 _isSmkProne = false; _ogPos = []; _newPos = []; _newAnim = ""; _plyr2 = objNull; //create variables we will use later as empty to prevent error...
  21.                 _ogPos = _this select 0; //grab the ogPos from the thread input
  22.                 _plyr2 = _this select 1; //grab player from the thread input
  23.                 //wait until: player has moved more than 0.00545 meters OR player is no longer in urban prone
  24.                 waitUntil{
  25.                     _newAnim = animationState _plyr2; _isSmkProne = [_newAnim,"smk_urbanprone"] call KRON_strInStr; _newPos = position _plyr2; _posDist = _newPos distance _ogPos;
  26.                     (((_isSmkProne) && (_posDist > 0.00545)) || (!_isSmkProne))
  27.                 };
  28.                
  29.                 if (!_isSmkProne) exitWith { }; //if player got out of urban prone without moving, exit without doing below code
  30.                 //player moved while in urban prone...
  31.                 (_this select 1) switchMove "amovppnemstpsraswrfldnon"; //switch player back to normal prone
  32.                 systemChat("[ZombZ] Anti-Wall-Crawl: You cannot move in this stance."); //send a message & exit
  33.             };
  34.         };
  35.     }]
Advertisement
Add Comment
Please, Sign In to add comment