Guest User

mindcontrol.pwn

a guest
Dec 20th, 2011
874
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.31 KB | None | 0 0
  1. // Mind control script created by JakeMan aka Celson.
  2.  
  3. #include <a_samp>
  4.  
  5. new controlling[MAX_PLAYERS];
  6.  
  7. new controlled[MAX_PLAYERS];
  8.  
  9. forward IsHoldingKey(playerid);
  10.  
  11. public OnPlayerDisconnect(playerid, reason)
  12. {
  13.     if(controlling[playerid] > 0)
  14.     {
  15.         ClearAnimations(controlling[playerid]-1);
  16.         SendClientMessage(controlling[playerid]-1,0xFFFFFFFF,"You are now free of mind control.");
  17.         controlled[controlling[playerid]-1] = 0;
  18.         controlling[playerid] = 0;
  19.     }
  20.     return 1;
  21. }
  22.  
  23. public OnPlayerSpawn(playerid)
  24. {
  25.     ApplyAnimation(playerid,"ped","null",0.0,0,0,0,0,0);
  26.     return 1;
  27. }
  28.  
  29. public OnPlayerCommandText(playerid, cmdtext[])
  30. {
  31.     new cmd[128], idx;
  32.     cmd = strtok(cmdtext, idx);
  33.     if(strcmp(cmd, "/control", true) == 0)
  34.     {
  35.         if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFF0000FF,"Only RCON admins can use this command.");
  36.         if(controlling[playerid] > 0) return SendClientMessage(playerid,0xFF0000FF,"You are already controlling someone.");
  37.         new tmp[128];
  38.         tmp = strtok(cmdtext, idx);
  39.         if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /control [ID]");
  40.         if(strval(tmp) == playerid) return SendClientMessage(playerid,0xFF0000FF, "You cannot use this command on yourself.");
  41.         if(!IsPlayerConnected(strval(tmp))) return SendClientMessage(playerid,0xFF0000FF, "Invalid ID");
  42.         if(GetPlayerState(strval(tmp)) != 1) return SendClientMessage(playerid,0xFF0000FF, "The victim must be on foot for you to control them.");
  43.         TogglePlayerSpectating(playerid, 1);
  44.         PlayerSpectatePlayer(playerid,strval(tmp));
  45.         controlling[playerid] = strval(tmp)+1;
  46.         controlled[strval(tmp)] = 1;
  47.         SetTimerEx("IsHoldingKey",100,0,"i",playerid);
  48.         new Float:rot;
  49.         ClearAnimations(strval(tmp));
  50.         GetPlayerFacingAngle(strval(tmp),rot);
  51.         SetPlayerFacingAngle(strval(tmp),floatmul(floatround(floatdiv(Float:rot,9.0),floatround_round),9.0));
  52.         return 1;
  53.     }
  54.     if(strcmp(cmd, "/ceasecontrol", true) == 0)
  55.     {
  56.         if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFF0000FF,"Only RCON admins can use this command.");
  57.         if(controlling[playerid] == 0) return SendClientMessage(playerid,0xFF0000FF,"You are not controlling anyone.");
  58.         ClearAnimations(controlling[playerid]-1);
  59.         SendClientMessage(controlling[playerid]-1,0xFFFFFFFF,"You are now free of mind control.");
  60.         controlled[controlling[playerid]-1] = 0;
  61.         controlling[playerid] = 0;
  62.         TogglePlayerSpectating(playerid, 0);
  63.         return 1;
  64.     }
  65.     return 0;
  66. }
  67.  
  68. public IsHoldingKey(playerid)
  69. {
  70.     if(controlling[playerid] > 0 && IsPlayerConnected(controlling[playerid]-1))
  71.     {
  72.         SetTimerEx("IsHoldingKey",100,0,"i",playerid);
  73.         new keys, updown, leftright;
  74.         GetPlayerKeys(playerid, keys, updown, leftright);
  75.         new victimid = controlling[playerid]-1;
  76.         new interior = GetPlayerInterior(victimid);
  77.         if(GetPlayerInterior(playerid) != interior) return SetPlayerInterior(playerid,interior);
  78.         if (leftright == KEY_LEFT && updown == KEY_UP)
  79.         {
  80.             new Float:Rot;
  81.             GetPlayerFacingAngle(victimid,Rot);
  82.             SetPlayerFacingAngle(victimid,Rot+9);
  83.         }
  84.         if (leftright == KEY_RIGHT && updown == KEY_UP)
  85.         {
  86.             new Float:Rot;
  87.             GetPlayerFacingAngle(victimid,Rot);
  88.             SetPlayerFacingAngle(victimid,Rot-9);
  89.         }
  90.         if (updown == KEY_UP)
  91.         {
  92.             if(keys == KEY_SPRINT)
  93.             {
  94.                 ApplyAnimation(victimid,"ped","sprint_civi",4.0,1,1,1,1,0);
  95.                 return 1;
  96.             }
  97.             if(keys == KEY_WALK)
  98.             {
  99.                 ApplyAnimation(victimid,"ped","WALK_player",4.0,1,1,1,1,0);
  100.                 return 1;
  101.             }
  102.             ApplyAnimation(victimid,"ped","run_player",4.0,1,1,1,1,0);
  103.             return 1;
  104.         }
  105.         ApplyAnimation(victimid,"ped","IDLE_stance",4.0,1,1,1,1,0);
  106.         return 1;
  107.     }
  108.     else
  109.     {
  110.         controlling[playerid] = 0;
  111.         TogglePlayerSpectating(playerid, 0);
  112.     }
  113.     return 1;
  114. }
  115.  
  116. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  117. {
  118.     if(controlled[playerid] == 1) return ClearAnimations(playerid);
  119.     return 1;
  120. }
  121.  
  122. strtok(const string[], &index)
  123. {
  124.     new length = strlen(string);
  125.     while ((index < length) && (string[index] <= ' '))
  126.     {
  127.         index++;
  128.     }
  129.  
  130.     new offset = index;
  131.     new result[20];
  132.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  133.     {
  134.         result[index - offset] = string[index];
  135.         index++;
  136.     }
  137.     result[index - offset] = EOS;
  138.     return result;
  139. }
Advertisement
Add Comment
Please, Sign In to add comment