Advertisement
Guest User

Untitled

a guest
Jun 9th, 2018
1,667
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.08 KB | None | 0 0
  1. quest ChangeNameWithVip begin
  2.     state start begin
  3.         function isNameAlready(pc_name)
  4.             local index, value = mysql_direct_query("SELECT player.player.name as name FROM player.player;");
  5.            
  6.             if (index > 0) then
  7.                 for num, str in ipairs(value) do
  8.                     if (string.lower(str.name) == string.lower(pc_name)) then return false; end
  9.                 end
  10.             end return true;
  11.         end
  12.        
  13.         function ChangeNameAddVip(new_Name)
  14.             return mysql_direct_query("UPDATE player.player SET name = '"..new_Name.."' WHERE name = '"..pc.get_name().."'");
  15.         end
  16.        
  17.         function isVipAlreadyAdded()
  18.             return pc.getqf("ChangeNameWithVipUsage") ~= 0;
  19.         end
  20.        
  21.         when 71173.use begin
  22.             if (ChangeNameWithVip.isVipAlreadyAdded()) then
  23.                 syschat("Poti adauga gradul [VIP] doar odata pe caracter!") return;
  24.             end
  25.            
  26.             say_title(string.format("%s:[ENTER]", item_name(item.get_vnum())))
  27.             say("Acest obiect ofera posibilitatea de a adauga[ENTER]gradul de [VIP] caracterului tau si[ENTER]cu posibilitatea de a schimba numele precedent[ENTER][ENTER]Doresti sa incepi procesul?")
  28.             if (select("Da", "Nu") == 1) then
  29.                 say_title(string.format("%s:[ENTER]", item_name(item.get_vnum())))
  30.                 say("Introdu numele dorit:")
  31.                 local strInput = string.gsub(input(), "[^A-Za-z0-9]", "");
  32.                 local input_len = string.len(strInput);
  33.                
  34.                 if (input_len < 3) then say("Numele tau trebuie sa contina cel putin[ENTER]3 caractere.") return; end
  35.                 if (input_len > 7) then say("Numele tau trebuie sa fie de maxim[ENTER]7 caractere.") return; end
  36.                 if (not ChangeNameWithVip.isNameAlready('[VIP]"..strInput.."')) then say("Acest nume a fost luat de catre alta persoana.[ENTER]Adaugarea numelui a fost anulata.") return; end
  37.                 if (not pc.can_warp()) then say("Asteapta 10 secunde de la inchiderea negotului.") return; end
  38.                
  39.                 say("Adaugarea gradului [VIP] a avut succes.[ENTER]Actualizarea acestuia se face dupa 15 min[ENTER]offline de pe caracter/cont.")
  40.                 ChangeNameWithVip.ChangeNameAddVip('[VIP]"..strInput.."');
  41.                 pc.setqf("ChangeNameWithVipUsage", 1);
  42.                 pc.remove_item(item.get_vnum(), 1);
  43.             end
  44.         end
  45.     end
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement