Advertisement
AutismAlex

uAntiLeave

Oct 23rd, 2019
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. //set this to the time in seconds before the player can leave after being damaged
  2. timeTillCanLeave = 10;
  3.  
  4.  
  5. antiLeaveData = array();
  6.  
  7. event onLoad(){
  8. database.execute("CREATE TABLE IF NOT EXISTS antiLeave(
  9. steamid VARCHAR(17) PRIMARY KEY
  10. );");
  11. }
  12.  
  13. event onPlayerDamaged(victim, attacker, cancel, cause, limb){
  14. if(victim.isAdmin == false){
  15. antiLeaveData.add(victim.id);
  16. victim.message("You have been damaged! You may not leave for " + timeTillCanLeave + " Seconds");
  17. wait.seconds(timeTillCanLeave, timeSpent(victim));
  18. }
  19. }
  20. event onPlayerQuit(player){
  21. foreach(val in antiLeaveData){
  22. if(val == player.id){
  23. database.execute("INSERT INTO antiLeave (steamid) VALUES ('" + player.id + "');");
  24. server.log(player.name + " Left Whilst In Combat!");
  25. }
  26. }
  27. }
  28. function timeSpent(player){
  29. foreach(val in antiLeaveData){
  30. if(val == player.id){
  31. antiLeaveData.remove(val);
  32. target = toPlayer(val[0]);
  33. if(isSet(target)){
  34. target.message("You May Now Leave");
  35. }
  36. }
  37. }
  38. }
  39. event onPlayerJoined(player){
  40. DBcheck = database.execute("SELECT * FROM antiLeave WHERE steamid = '" + player.id + "';");
  41. DBcheck = DBcheck[0];
  42. if(DBcheck.count != 0){
  43. player.kill();
  44. player.message("Due To You Leaving In Combat You Have Been Killed");
  45. }
  46. database.execute("DELETE FROM antiLeave WHERE steamid = '" + player.id + "';");
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement