Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //set this to the time in seconds before the player can leave after being damaged
- timeTillCanLeave = 10;
- antiLeaveData = array();
- event onLoad(){
- database.execute("CREATE TABLE IF NOT EXISTS antiLeave(
- steamid VARCHAR(17) PRIMARY KEY
- );");
- }
- event onPlayerDamaged(victim, attacker, cancel, cause, limb){
- if(victim.isAdmin == false){
- antiLeaveData.add(victim.id);
- victim.message("You have been damaged! You may not leave for " + timeTillCanLeave + " Seconds");
- wait.seconds(timeTillCanLeave, timeSpent(victim));
- }
- }
- event onPlayerQuit(player){
- foreach(val in antiLeaveData){
- if(val == player.id){
- database.execute("INSERT INTO antiLeave (steamid) VALUES ('" + player.id + "');");
- server.log(player.name + " Left Whilst In Combat!");
- }
- }
- }
- function timeSpent(player){
- foreach(val in antiLeaveData){
- if(val == player.id){
- antiLeaveData.remove(val);
- target = toPlayer(val[0]);
- if(isSet(target)){
- target.message("You May Now Leave");
- }
- }
- }
- }
- event onPlayerJoined(player){
- DBcheck = database.execute("SELECT * FROM antiLeave WHERE steamid = '" + player.id + "';");
- DBcheck = DBcheck[0];
- if(DBcheck.count != 0){
- player.kill();
- player.message("Due To You Leaving In Combat You Have Been Killed");
- }
- database.execute("DELETE FROM antiLeave WHERE steamid = '" + player.id + "';");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement