Jump to content

Sande

Members
  • Posts

    186
  • Joined

  • Last visited

Everything posted by Sande

  1. Hello, i´m trying to make a login system for my server. But because i am beginner on these login i can not complete it. I have been search many info from wiki and forums how to make the functions and the login function working already. Register functions works too but there is some little problems like you can register while you have empty boxes etc. I dont have any idea how to check that things and the code are so messed up. If someone can fix my code i will be happy. I can pay something for the fixer when i get money to my paypal. !But the "remember me" functions should work then. Server-side: function loginHandler(username,password) -- check that the username and password are correct local account = getAccount ( username, password ) if ( account ~= false ) then logIn(source, account, password) -- the player has successfully logged in, so spawn them if (client) then spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) setCameraTarget(client, client) outputChatBox("Welcome to My Server.", client) end else -- if the username or password are not correct, output a message to the player outputChatBox("Invalid username and password. Please try again.",client) triggerClientEvent (source,"openLogin",getRootElement()) end end addEvent("submitLogin",true) addEventHandler("submitLogin",root,loginHandler) function register (username,password, passwordC) local account = getAccount (username,password) if (account == false) then local accountAdded = addAccount(tostring(username),tostring(password)) if (accountAdded) then outputChatBox ("#FF0000* #00FF00You have sucessfuly registered! [username: #FFFFFF" .. username .. " #00FF00| Password: #FFFFFF" .. password .. "#00FF00 ]",source,255,255,255,true ) logIn(source, account, password) if (client) then spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) setCameraTarget(client, client) outputChatBox("Welcome to My Server.", client) else outputChatBox("Error while registering new account!", source, 255,0,0) triggerClientEvent (source,"openLogin",getRootElement()) end end end end addEvent("submitRegister",true) addEventHandler("submitRegister",root,register) Client-side --[[------------------------------------------------- Notes: > This code is using a relative image filepath. This will only work as long as the location it is from always exists, and the resource it is part of is running. To ensure it does not break, it is highly encouraged to move images into your local resource and reference them there. --]]------------------------------------------------- function createLoginWindow() Loginpanel = { tab = {}, staticimage = {}, tabpanel = {}, edit = {}, button = {}, window = {}, label = {}, checkbox = {} } Loginpanel.window[1] = guiCreateWindow(681, 346, 542, 428, "Suomisisu", false) guiWindowSetSizable(Loginpanel.window[1], false) Loginpanel.tabpanel[1] = guiCreateTabPanel(9, 20, 523, 398, false, Loginpanel.window[1]) Loginpanel.tab[1] = guiCreateTab("Login", Loginpanel.tabpanel[1]) Loginpanel.staticimage[1] = guiCreateStaticImage(10, 5, 503, 90, ":lol/logo.png", false, Loginpanel.tab[1]) edtUser = guiCreateEdit(190, 155, 161, 24, "", false, Loginpanel.tab[1]) edtPass = guiCreateEdit(190, 226, 161, 24, "", false, Loginpanel.tab[1]) Loginpanel.label[1] = guiCreateLabel(191, 135, 156, 15, "Username:", false, Loginpanel.tab[1]) guiSetFont(Loginpanel.label[1], "default-bold-small") Loginpanel.label[2] = guiCreateLabel(191, 211, 156, 15, "Password:", false, Loginpanel.tab[1]) guiSetFont(Loginpanel.label[2], "default-bold-small") Loginpanel.checkbox[1] = guiCreateCheckBox(190, 265, 157, 15, "Remember me", true, false, Loginpanel.tab[1]) guiSetFont(Loginpanel.checkbox[1], "default-bold-small") btnLogin = guiCreateButton(188, 336, 163, 18, "Login", false, Loginpanel.tab[1]) guiSetFont(Loginpanel.button[1], "default-bold-small") Loginpanel.tab[2] = guiCreateTab("Register", Loginpanel.tabpanel[1]) Loginpanel.staticimage[2] = guiCreateStaticImage(10, 5, 503, 90, ":lol/logo.png", false, Loginpanel.tab[2]) edtUserR = guiCreateEdit(188, 141, 165, 24, "", false, Loginpanel.tab[2]) edtPass1 = guiCreateEdit(188, 198, 165, 24, "", false, Loginpanel.tab[2]) edtPass2 = guiCreateEdit(188, 247, 165, 24, "", false, Loginpanel.tab[2]) btnRegister = guiCreateButton(188, 339, 166, 18, "Register", false, Loginpanel.tab[2]) guiSetFont(Loginpanel.button[2], "default-bold-small") Loginpanel.label[3] = guiCreateLabel(192, 121, 155, 15, "Username:", false, Loginpanel.tab[2]) guiSetFont(Loginpanel.label[3], "default-bold-small") Loginpanel.label[4] = guiCreateLabel(189, 183, 164, 15, "Password:", false, Loginpanel.tab[2]) guiSetFont(Loginpanel.label[4], "default-bold-small") Loginpanel.label[5] = guiCreateLabel(189, 232, 164, 15, "Password:", false, Loginpanel.tab[2]) guiSetFont(Loginpanel.label[5], "default-bold-small") Loginpanel.checkbox[2] = guiCreateCheckBox(188, 286, 200, 15, "I accept suomisisu terms of use", true, false, Loginpanel.tab[2]) guiSetFont(Loginpanel.checkbox[2], "default-bold-small") Loginpanel.tab[3] = guiCreateTab("Rules", Loginpanel.tabpanel[1]) Loginpanel.label[6] = guiCreateLabel(1, 3, 518, 366, " 1. Ei hakkerointia, tai muuta mikä häiritsee serverin toimintaa.\n 2. Chattiin spämminen on kiellettyä.\n 3. Älä kerjaa admin/mode oikeuksia\n 4. Tottele henkilökuntaa kaikissa tilanteissa\n 5. Älä sabotoi serveriä\n 6. Älä varasta toisen käyttäjätiliä / yritä onkia salasanoja\n 7. Älä mainosta muita palvelimia\n 8. Älä häiritse muita pelaajia jatkuvasti tappamalla heitä\n 9. Älä warp-tapa\n 10. Älä spawn-tapa\n 11. Henkilökuntaa ei saa häiritä jos hän on on-duty tilassa\n 12. Henkilökunnan jäsentä ei saa tappaa jos hän on on-duty tilassa..\n 13. Trainereiden käyttö on kiellettyä.\n 14. Bugien hyödyntäminen on kiellettyä, jos löydät bugin ilmoita siitä adminille.\n 15. Ilkivalta henkilökunnan & vippien autoja kohtaan on kiellettyä.\n 16. Et saa käyttää toisten pelaajien nimiä\n\n Jos et noudata yllämainittuja sääntöjä on henkilökunalla oikeus antaa sinulle porttikielto\n palvelimelle.\n\n Porttikiellon kesto riippuu sääntörikkeestä ja sen vakavuudesta.\n\n Nämä säännöt hyväksyt joka kerta kun menet palvelimelle.\n Pidämme kaikki oikeudet sääntöjenmuutoksiin.\n", false, Loginpanel.tab[3]) guiSetFont(Loginpanel.label[6], "default-bold-small") guiLabelSetHorizontalAlign(Loginpanel.label[6], "left", true) Loginpanel.tab[4] = guiCreateTab("Info", Loginpanel.tabpanel[1]) Loginpanel.label[7] = guiCreateLabel(3, 5, 515, 359, "Suomisisu mtapalvelin aloitettiin lainelaitoksen kaatumisen aikoina, serveri oli alunperin suuniteltu vain sanden ja vlackin hauskanpito serveriksi. Serverille alkoi kuitenkin virrata pelaajia ja päätimme aloittaa ihan operoimaan serveriä.\n\nSuomisisun ylläpitotiimiin kuuluu:\nSisuviina - Omistaja\nSuokkola - Toinen omistaja\nSinetti - Ylläpitäjä\nFinnPlaya - Ylläpitäjä\nNikkop99 - Päämoderaattori\n\nErityiskiitokset:\n[Dj]Wolf_fin - Lahjoittaja\nMonkey_Dr!fter - Lahjoittaja\nJonskuGameGod - Lahjoittaja\nCookieZ - Lahjoittaja\nMrEllux - Lahjoittaja\n\nSuomisisun omistaa BGSOF eli Best gaming servers of finland yhteisö jota Sisuviina ylläpitää.\n\nServerin nettisivut:\nbgsof.com - Pääsivu\nbgsof.com/Forkka - Foorumi\nbgsof.com/Filecenter - Tiedostopalvelu\n\n© Suomisisu & Bgsof 2012-2014", false, Loginpanel.tab[4]) guiSetFont(Loginpanel.label[7], "default-bold-small") guiLabelSetHorizontalAlign(Loginpanel.label[7], "left", true) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) addEventHandler("onClientGUIClick", btnRegister, clientSubmitRegister, false) end function show() -- create the log in window and its components createLoginWindow() -- output a brief welcome message to the player --outputChatBox("Welcome to My MTA:SA Server, please log in.") -- if the GUI was successfully created, then show the GUI to the player if (Loginpanel.window[1] ~= nil) then guiSetVisible(Loginpanel.window[1], true) else -- if the GUI hasnt been properly created, tell the player outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") end -- enable the players cursor (so they can select and click on the components) showCursor(true) -- set the input focus onto the GUI, allowing players (for example) to press 'T' without the chatbox opening guiSetInputEnabled(true) end addEvent("openLogin",true) addEventHandler("openLogin",root,show) addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function (username, password) -- create the log in window and its components createLoginWindow() -- output a brief welcome message to the player outputChatBox("Welcome to My MTA:SA Server, please log in.") -- if the GUI was successfully created, then show the GUI to the player if (Loginpanel.window[1] ~= nil) then guiSetVisible(Loginpanel.window[1], true) else -- if the GUI hasnt been properly created, tell the player outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") end -- enable the players cursor (so they can select and click on the components) showCursor(true) -- set the input focus onto the GUI, allowing players (for example) to press 'T' without the chatbox opening guiSetInputEnabled(true) end ) function clientSubmitLogin(button,state) if button == "left" and state == "up" then -- get the text entered in the 'username' field local username = guiGetText(edtUser) -- get the text entered in the 'password' field local password = guiGetText(edtPass) -- if the username and password both exist if username and password then -- trigger the server event 'submitLogin' and pass the username and password to it triggerServerEvent("submitLogin", getRootElement(), username, password) -- hide the gui, hide the cursor and return control to the player guiSetInputEnabled(false) guiSetVisible(Loginpanel.window[1], false) showCursor(false) else -- otherwise, output a message to the player, do not trigger the server -- and do not hide the gui outputChatBox("Please enter a username and password.") end end end function clientSubmitRegister(button,state) if button == "left" and state == "up" then -- get the text entered in the 'username' field local username = guiGetText(edtUserR) -- get the text entered in the 'password' field local password = guiGetText(edtPass1) local passwordC = guiGetText(edtPass2) -- if the username and password both exist if username and password and password == passwordC then -- trigger the server event 'submitLogin' and pass the username and password to it triggerServerEvent("submitRegister", getRootElement(), username, password, passwordC) -- hide the gui, hide the cursor and return control to the player guiSetInputEnabled(false) guiSetVisible(Loginpanel.window[1], false) showCursor(false) else -- otherwise, output a message to the player, do not trigger the server -- and do not hide the gui outputChatBox("Please enter a username and password, and make sure the password boxes contains same password.") end end end function loadLoginFromXML() --Загрузка логина и пароля из XML local xml_save_log_File = xmlLoadFile ("files/xml/userdata.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/userdata.xml", "login") end local usernameNode = xmlFindChild (xml_save_log_File, "username", 0) local passwordNode = xmlFindChild (xml_save_log_File, "password", 0) if usernameNode and passwordNode then return xmlNodeGetValue(usernameNode), xmlNodeGetValue(passwordNode) else return "", "" end xmlUnloadFile ( xml_save_log_File ) end function saveLoginToXML(username, password) --Сохрание логина и пароля в XML local xml_save_log_File = xmlLoadFile ("files/xml/userdata.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/userdata.xml", "login") end if (username ~= "") then local usernameNode = xmlFindChild (xml_save_log_File, "username", 0) if not usernameNode then usernameNode = xmlCreateChild(xml_save_log_File, "username") end xmlNodeSetValue (usernameNode, tostring(username)) end if (password ~= "") then local passwordNode = xmlFindChild (xml_save_log_File, "password", 0) if not passwordNode then passwordNode = xmlCreateChild(xml_save_log_File, "password") end xmlNodeSetValue (passwordNode, tostring(password)) end xmlSaveFile(xml_save_log_File) xmlUnloadFile (xml_save_log_File) end addEvent("saveLoginToXML", true) addEventHandler("saveLoginToXML", getRootElement(), saveLoginToXML) function resetSaveXML() --Сохрание логина и пароля в XML local xml_save_log_File = xmlLoadFile ("files/xml/userdata.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/userdata.xml", "login") end if (username ~= "") then local usernameNode = xmlFindChild (xml_save_log_File, "username", 0) if not usernameNode then usernameNode = xmlCreateChild(xml_save_log_File, "username") end end if (password ~= "") then local passwordNode = xmlFindChild (xml_save_log_File, "password", 0) if not passwordNode then passwordNode = xmlCreateChild(xml_save_log_File, "password") end xmlNodeSetValue (passwordNode, "") end xmlSaveFile(xml_save_log_File) xmlUnloadFile (xml_save_log_File) end addEvent("resetSaveXML", true) addEventHandler("resetSaveXML", getRootElement(), resetSaveXML)
  2. @Twerky thank you very very much!
  3. Oh theres a solution. Any idea how to make speedometer for all resolutions? @Wassim 1920 x 1080
  4. I mean, other players say they didn´t see it. But i see it. They taked screenshots.
  5. Somereason i can only see the speedometer . If someone can give a solution how to fix that, then i am happy. function speedoCreate() if isPedInVehicle (localPlayer) == false then return end sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) local kmhs = math.floor(((sx^2 + sy^2 + sz^2)^(0.5))*180) local x, y, z = getElementPosition(localPlayer) vehicle = getVehicleName (getPedOccupiedVehicle(localPlayer)) health = getElementHealth (getPedOccupiedVehicle(localPlayer)) currenthealth = math.floor(health/10) dxDrawText("Speed: "..tostring(kmhs).."km/h", 1701, 956, 1924, 977, tocolor(255, 255, 255, 255), 2.00, "default", "left", "top", false, false, true, false, false) dxDrawText("Health: "..tostring(currenthealth).."%", 1701, 987, 1924, 1008, tocolor(255, 255, 255, 255), 2.00, "default", "left", "top", false, false, true, false, false) dxDrawRectangle(1700, 924, 191, 95, tocolor(0, 0, 0, 255), false) dxDrawRectangle(1701, 925, 189, 93, tocolor(27, 27, 27, 254), false) dxDrawText(""..tostring(vehicle).."", 1701, 925, 1855, 956, tocolor(255, 255, 255, 255), 2.00, "default", "left", "top", false, false, true, false, false) end addEventHandler("onClientRender",getRootElement(),speedoCreate) function show ( player ) if ( player == localPlayer ) then addEventHandler ( "onClientRender", getRootElement(), speedoCreate ) end end addEventHandler ("onClientVehicleEnter", getRootElement(), show) function hide ( player ) if ( player == localPlayer ) then removeEventHandler ( "onClientRender", getRootElement(), speedoCreate ) end end addEventHandler ("onClientVehicleExit", getRootElement(), hide)
  6. Hello, i have problem with my script. The problem is after the check occupation part, if there is criminal(thePlayer), it doesn´t run the function. This script should work like this: If player occupation is criminal, then this script sets him to criminal team. function jonne() local players = getElementsByType ( "player" ) for theKey,thePlayer in ipairs(players) do if ( thePlayer ) then local occ = getElementData(thePlayer, "Occupation") if occ == false then return end if getElementData(thePlayer, "Occupation") == "Criminal" then criminal(thePlayer) outputChatBox("Criminal-found") return end elseif getElementData(thePlayer, "Occupation") == "Police" then police(thePlayer) elseif getElementData(thePlayer, "Occupation") == "Trucker" then trucker(thePlayer) elseif getElementData(thePlayer, "Occupation") == "Medic" then medic(thePlayer) elseif getElementData(thePlayer, "Occupation") == "Freeroam" then freeroam(thePlayer) elseif getElementData(thePlayer, "Occupation") == "Staff" then staff(thePlayer) elseif getElementData(thePlayer, "Occupation") == "Unemployed" then unemployed(thePlayer) elseif getElementData(thePlayer, "Occupation") == "FBI Agent" then fbi(thePlayer) elseif getElementData(thePlayer, "Occupation") == "Army" then army(thePlayer) elseif getElementData(thePlayer, "Occupation") == "SWAT Agent" then swat(thePlayer) else setElementData(thePlayer, "Occupation", "Unemployed") setPlayerTeam(thePlayer, getTeamFromName("Unemployed")) end end end function timer1() setTimer(jonne, 500, 0) end function army(thePlayer) --local team4 = getTeamFromName("Army") setPlayerTeam(thePlayer, getTeamFromName("Army")) end function fbi(thePlayer) --local team5 = getTeamFromName("FBI") setPlayerTeam(thePlayer, getTeamFromName("FBI")) end function swat(thePlayer) --local team6 = getTeamFromName("SWAT") setPlayerTeam(thePlayer, getTeamFromName("SWAT")) end function staff(thePlayer) --local team7 = getTeamFromName("Staff") setPlayerTeam(thePlayer, getTeamFromName("Staff")) end function freeroam(thePlayer) --local team8 = getTeamFromName("Freeroam") setPlayerTeam(thePlayer, getTeamFromName("Freeroam")) end function unemployed(thePlayer) --local team9 = getTeamFromName("Unemployed") setPlayerTeam(thePlayer, getTeamFromName("Unemployed")) end --[[function criminal(thePlayer) --local team = getTeamFromName("Criminal") outputChatBox("Criminal-set") setPlayerTeam(thePlayer, getTeamFromName("Criminal")) end--]] function police(thePlayer) --local team1 = getTeamFromName("Police") setPlayerTeam(thePlayer, getTeamFromName("Police")) end function trucker(thePlayer) --local team2 = getTeamFromName("Civilians") setPlayerTeam(thePlayer, getTeamFromName("Civilians")) end function medic(thePlayer) --local team3 = getTeamFromName("Emergency") setPlayerTeam(thePlayer, getTeamFromName("Emergency")) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), jonne )
  7. Create groupbank, it will be nice
  8. Thanks for replies. I have been stopped scripting because i am too bad in lua. Thread closed.
  9. Hello, i ´m trying to make anti troll system what have to work like this: If same player kills someplayer many times like 10 times. It puts gui to the killed player screen and he have´s option punish or forgive these kills. Now the problem is the functions not working and i am not good with these things. So if someone can help me little i will be so happy. Server: function player_Wasted ( ammo, attacker, weapon, bodypart ) if ( attacker ) then if getElementData(attacker, "anti-troll-kills") then local kills = getElementData(attacker, "anti-troll-kills") setElementData(attacker, "anti-troll-kills", getElementData(attacker, "anti-troll-kills")+1) if kills >= 1 and kills <= 2 then triggerClientEvent ( "antitroll", getRootElement(), attacker ) else setElementData(attacker, "anti-troll-kills", 1) end end end end addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted ) function Forgive(attacker) setElementData(attacker, "anti-troll-kills", 0) end addEvent( "antiforgive", true ) addEventHandler( "antiforgive", root, Forgive ) function Punish(attacker) setElementInterior ( attacker, 6 ) setElementPosition (attacker, 265.21185302734, 77.63591003418, 1001.0390625) setElementPosition ( 300000, 1, attacker, 268.03460693359, 77.43824005127, 1001.03906) setElementData(attacker, "anti-troll-kills", 0) setTimer(unjail, 65000, 1) end addEvent( "antipunish", true ) addEventHandler( "antipunish", root, Punish ) function unjail(attacker) setElementInterior ( attacker, 0) setElementPosition ( attacker, 268.03460693359, 77.43824005127, 1001.03906) end Client: function createGUI() Antipanel = { button = {}, window = {}, label = {} } Antipanel.window[1] = guiCreateWindow(808, 482, 321, 170, "Suomisisu - Anti troll", false) guiWindowSetSizable(Antipanel.window[1], false) Antipanel.button[1] = guiCreateButton(10, 84, 138, 72, "Forgive", false, Antipanel.window[1]) guiSetProperty(Antipanel.button[1], "NormalTextColour", "FF11FD00") Antipanel.button[2] = guiCreateButton(154, 85, 157, 71, "Punish", false, Antipanel.window[1]) guiSetProperty(Antipanel.button[2], "NormalTextColour", "FFFE0000") Antipanel.label[1] = guiCreateLabel(10, 25, 301, 50, "You have been killed many times by: ... \nYou have now option to choice what do you want to do to that troll.", false, Antipanel.window[1]) guiLabelSetColor(Antipanel.label[1], 252, 244, 0) guiLabelSetHorizontalAlign(Antipanel.label[1], "left", true) addEventHandler ( "onClientGUIClick", Antipanel.button[1], Forgive, false ) addEventHandler ( "onClientGUIClick", Antipanel.button[2], Punish, false ) guiSetVisible(Antipanel.window[1], false) end addEventHandler ("onClientResourceStart", getResourceRootElement(getThisResource()), createGUI) function Forgive(attacker) triggerServerEvent ( "antiforgive", localPlayer, attacker ) windowcloseopen(localPlayer) end function Punish(attacker) triggerServerEvent ( "antipunish", localPlayer, attacker ) windowcloseopen(localPlayer) end function windowcloseopen () if (guiGetVisible (Antipanel.window[1]) == true) then guiSetVisible (Antipanel.window[1], false) guiSetInputEnabled (false) showCursor (false) elseif (guiGetVisible (Antipanel.window[1]) == false) then guiSetVisible (Antipanel.window[1], true) showCursor (true) end end addEvent( "antitroll", true ) addEventHandler( "antitroll", getLocalPlayer(), windowcloseopen )
  10. Problem fixxed, added: dataName,oldValue to the function arguments.
  11. it gets false. but its not false in my account.
  12. Putted return with debug message, its all time returning. so the message is appear all time. outputDebugString("return shit")
  13. still this shit doesnt work, no debugs. local criminal1 = { "Criminal", "Street Rat", "0" } local criminal2 = { "Criminal", "Mugger", "100" } local criminal3 = { "Criminal", "Mobster", "200" } local criminal4 = { "Criminal", "Mercenary", "300" } local criminal5 = { "Criminal", "Kingpin", "500" } local police1 = { "Police", "Trainee", "0" } local police2 = { "Police", "Officer", "100" } local police3 = { "Police", "Head officer", "200" } local police4 = { "Police", "Marshall", "300" } local police5 = { "Police", "FBI Agent", "500" } --TEAM, OCCUPATION, RANKNAME, REQUIRED ACTIONS local civilian1 = { "Civilians", "Trucker", "Trucker Wannabe", "0" } local civilian2 = { "Civilians", "Trucker", "Rookietrucker", "50" } local civilian3 = { "Civilians", "Trucker", "Transport Tycoon", "75" } local civilian4 = { "Civilians", "Trucker", "Hauler", "100" } local civilian5 = { "Civilians", "Trucker", "King of the road", "150" } local emergency1 = { "Emergency", "Medic", "EMT", "0" } local emergency2 = { "Emergency", "Medic", "Nurse", "25" } local emergency3 = { "Emergency", "Medic", "Paramedic", "50" } local emergency4 = { "Emergency", "Medic", "Doctor", "75" } local emergency5 = { "Emergency", "Medic", "Surgeon", "100" } --outputChatBox ( criminal [ 1 ] ) -- bar --outputChatBox ( criminal [ 2 ] ) -- baz --outputChatBox ( criminal [ 3 ] ) -- anything function timer() setTimer(checkIfRankUp, 5000, 0) end function checkIfRankUp(source) if getElementData ( source, "Occupation" ) == "Criminal" then local crimActions = getElementData(source, "Criminal-actions" ) local occ = getElementData(source, "Occupation") if crimActions >= 99 and crimActions <= 199 then setElementData(source, "Rank", criminal2 [ 2 ] ) elseif crimActions >= 199 and crimActions <= 299 then setElementData(source, "Rank", criminal3 [ 2 ] ) elseif crimActions >= 299 and crimActions <= 499 then setElementData(source, "Rank", criminal4 [ 2 ] ) elseif crimActions >= 499 and crimActions <= 900 then setElementData(source, "Rank", criminal5 [ 2 ] ) elseif crimActions == 0 then setElementData(source, "Rank", criminal1 [ 2 ] ) end --outputDebugString("Crimi") elseif getElementData ( source, "Occupation" ) == "Police" then local polcActions = getElementData(source, "Police-actions" ) local occ = getElementData(source, "Occupation") if polcActions >= 99 and polcActions <= 199 then setElementData(source, "Rank", police2 [ 2 ] ) elseif polcActions >= 199 and polcActions <= 299 then setElementData(source, "Rank", police3 [ 2 ] ) elseif polcActions >= 299 and polcActions <= 499 then setElementData(source, "Rank", police4 [ 2 ] ) elseif polcActions >= 499 and polcActions <= 900 then setElementData(source, "Rank", police5 [ 2 ] ) elseif polcActions == 0 then setElementData(source, "Rank", police1 [ 2 ] ) end --outputDebugString("Poli") elseif getElementData ( source, "Occupation" ) == "Trucker" then local trucActions = getElementData(source, "Trucker-actions" ) local occ = getElementData(source, "Occupation") if trucActions >= 0 and trucActions <= 49 then setElementData(source, "Rank", civilian2 [ 3 ] ) elseif trucActions>= 49 and trucActions <= 74 then setElementData(source, "Rank", civilian3 [ 3 ] ) elseif trucActions >= 74 and trucActions <= 99 then setElementData(source, "Rank", civilian4 [ 3 ] ) elseif trucActions >= 99 and trucActions <= 149 then setElementData(source, "Rank", civilian5 [ 3 ] ) elseif trucActions == 0 then setElementData(source, "Rank", civilian1 [ 3 ] ) end elseif getElementData ( source, "Occupation" ) == "Medic" then local mediActions = getElementData(source, "Medic-actions" ) local occ = getElementData(source, "Occupation") if mediActions >= 0 and mediActions <= 24 then setElementData(source, "Rank", emergency2 [ 3 ] ) elseif mediActions>= 24 and mediActions <= 49 then setElementData(source, "Rank", emergency3 [ 3 ] ) elseif mediActions>= 49 and mediActions <= 74 then setElementData(source, "Rank", emergency4 [ 3 ] ) elseif mediActions >= 74 and mediActions <= 99 then setElementData(source, "Rank", emergency5 [ 3 ] ) elseif mediActions == 0 then setElementData(source, "Rank", emergency1 [ 3 ] ) end elseif getElementData ( source, "Occupation" ) == "Freeroam" then setElementData(source, "Occupation", "Freeroam") setElementData(source, "Rank", "Insane") elseif getElementData ( source, "Occupation" ) == "Unemployed" then setElementData(source, "Occupation", "Unemployed") setElementData(source, "Rank", "Unemployed") else return end end addEventHandler("onElementDataChange",getRootElement(),checkIfRankUp)
  14. Lol, i never hear about: onElementData change, but i think it doesn´t working if i re-script it
  15. Sande

    House Icon

    oh thanks, but does anybody have a clue why its a pickup and not a marker? Because markers and pickups are diffrent things.
  16. Sande

    House Icon

    This is for green house pickup: local x,y,z = coordinates createPickup ( x, y, z, 1273) and if you want blue pickup change the 1273 to 1272.
  17. No, thats one reason why i am tired to fix it. I debugged it too like it output things when it check occupation, but anything goes to debug. Also the file is in meta.xml and no errors in debug. It just doesn´t work. that criminal-actions and other elementData is setted too to my account. So i dont really know what is the problem.
  18. Hello, i have been created a rank system 2-3days ago. But still cant get it working. The problem is somewhere when the script gets thePlayer or gets thePlayer elementDatas. local criminal1 = { "Criminal", "Street Rat", "0" } local criminal2 = { "Criminal", "Mugger", "100" } local criminal3 = { "Criminal", "Mobster", "200" } local criminal4 = { "Criminal", "Mercenary", "300" } local criminal5 = { "Criminal", "Kingpin", "500" } local police1 = { "Police", "Trainee", "0" } local police2 = { "Police", "Officer", "100" } local police3 = { "Police", "Head officer", "200" } local police4 = { "Police", "Marshall", "300" } local police5 = { "Police", "FBI Agent", "500" } --TEAM, OCCUPATION, RANKNAME, REQUIRED ACTIONS local civilian1 = { "Civilians", "Trucker", "Trucker Wannabe", "0" } local civilian2 = { "Civilians", "Trucker", "Rookietrucker", "50" } local civilian3 = { "Civilians", "Trucker", "Transport Tycoon", "75" } local civilian4 = { "Civilians", "Trucker", "Hauler", "100" } local civilian5 = { "Civilians", "Trucker", "King of the road", "150" } local emergency1 = { "Emergency", "Medic", "EMT", "0" } local emergency2 = { "Emergency", "Medic", "Nurse", "25" } local emergency3 = { "Emergency", "Medic", "Paramedic", "50" } local emergency4 = { "Emergency", "Medic", "Doctor", "75" } local emergency5 = { "Emergency", "Medic", "Surgeon", "100" } --outputChatBox ( criminal [ 1 ] ) -- bar --outputChatBox ( criminal [ 2 ] ) -- baz --outputChatBox ( criminal [ 3 ] ) -- anything function timer() setTimer(checkIfRankUp, 5000, 0) end function checkIfRankUp() local players = getElementsByType ( "player" ) for theKey,thePlayer in ipairs(players) do if ( thePlayer ) then if getElementData ( thePlayer, "Occupation" ) == "Criminal" then local crimActions = getElementData(thePlayer, "Criminal-actions" ) local occ = getElementData(thePlayer, "Occupation") if crimActions >= 99 and crimActions <= 199 then setElementData(thePlayer, "Rank", criminal2 [ 2 ] ) elseif crimActions >= 199 and crimActions <= 299 then setElementData(thePlayer, "Rank", criminal3 [ 2 ] ) elseif crimActions >= 299 and crimActions <= 499 then setElementData(thePlayer, "Rank", criminal4 [ 2 ] ) elseif crimActions >= 499 and crimActions <= 900 then setElementData(thePlayer, "Rank", criminal5 [ 2 ] ) elseif crimActions == 0 then setElementData(thePlayer, "Rank", criminal1 [ 2 ] ) end --outputDebugString("Crimi") elseif getElementData ( thePlayer, "Occupation" ) == "Police" then local polcActions = getElementData(thePlayer, "Police-actions" ) local occ = getElementData(thePlayer, "Occupation") if polcActions >= 99 and polcActions <= 199 then setElementData(thePlayer, "Rank", police2 [ 2 ] ) elseif polcActions >= 199 and polcActions <= 299 then setElementData(thePlayer, "Rank", police3 [ 2 ] ) elseif polcActions >= 299 and polcActions <= 499 then setElementData(thePlayer, "Rank", police4 [ 2 ] ) elseif polcActions >= 499 and polcActions <= 900 then setElementData(thePlayer, "Rank", police5 [ 2 ] ) elseif polcActions == 0 then setElementData(thePlayer, "Rank", police1 [ 2 ] ) end --outputDebugString("Poli") elseif getElementData ( thePlayer, "Occupation" ) == "Trucker" then local trucActions = getElementData(thePlayer, "Trucker-actions" ) local occ = getElementData(thePlayer, "Occupation") if trucActions >= 0 and trucActions <= 49 then setElementData(thePlayer, "Rank", civilian2 [ 3 ] ) elseif trucActions>= 49 and trucActions <= 74 then setElementData(thePlayer, "Rank", civilian3 [ 3 ] ) elseif trucActions >= 74 and trucActions <= 99 then setElementData(thePlayer, "Rank", civilian4 [ 3 ] ) elseif trucActions >= 99 and trucActions <= 149 then setElementData(thePlayer, "Rank", civilian5 [ 3 ] ) elseif trucActions == 0 then setElementData(thePlayer, "Rank", civilian1 [ 3 ] ) end elseif getElementData ( thePlayer, "Occupation" ) == "Medic" then local mediActions = getElementData(thePlayer, "Medic-actions" ) local occ = getElementData(thePlayer, "Occupation") if mediActions >= 0 and mediActions <= 24 then setElementData(thePlayer, "Rank", emergency2 [ 3 ] ) elseif mediActions>= 24 and mediActions <= 49 then setElementData(thePlayer, "Rank", emergency3 [ 3 ] ) elseif mediActions>= 49 and mediActions <= 74 then setElementData(thePlayer, "Rank", emergency4 [ 3 ] ) elseif mediActions >= 74 and mediActions <= 99 then setElementData(thePlayer, "Rank", emergency5 [ 3 ] ) elseif mediActions == 0 then setElementData(thePlayer, "Rank", emergency1 [ 3 ] ) end elseif getElementData ( thePlayer, "Occupation" ) == "Freeroam" then setElementData(thePlayer, "Occupation", "Freeroam") setElementData(thePlayer, "Rank", "Insane") elseif getElementData ( thePlayer, "Occupation" ) == "Unemployed" then setElementData(thePlayer, "Occupation", "Unemployed") setElementData(thePlayer, "Rank", "Unemployed") else return end end end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), timer )
  19. yes, but its now not using that part of table to checking that. So do you know why this is not working?
  20. Look your self: The Bug Is I have this radio script and the problem is that when the player is in a vehicle, sometimes the radio stations gets removed automatically, fix this problem ty ! and i need a little help, so i can hear the music playing from another player's car when im outside of a vehicle --FIX THIS PROBLEM TY.. So you cant say anything about me. Im trying to do system what increasing your rank if you have required criminal-actions or medic, or trucker or police actions.
  21. Hello, i have been created a rank system but somereason it doesnt working. No errors or anything in debug. Code: local criminal1 = { "Criminal", "Street Rat", "0" } local criminal2 = { "Criminal", "Mugger", "100" } local criminal3 = { "Criminal", "Mobster", "200" } local criminal4 = { "Criminal", "Mercenary", "300" } local criminal5 = { "Criminal", "Kingpin", "500" } local police1 = { "Police", "Trainee", "0" } local police2 = { "Police", "Officer", "100" } local police3 = { "Police", "Head officer", "200" } local police4 = { "Police", "Marshall", "300" } local police5 = { "Police", "FBI Agent", "500" } --TEAM, OCCUPATION, RANKNAME, REQUIRED ACTIONS local civilian1 = { "Civilians", "Trucker", "Trucker Wannabe", "0" } local civilian2 = { "Civilians", "Trucker", "Rookietrucker", "50" } local civilian3 = { "Civilians", "Trucker", "Transport Tycoon", "75" } local civilian4 = { "Civilians", "Trucker", "Hauler", "100" } local civilian5 = { "Civilians", "Trucker", "King of the road", "150" } local emergency1 = { "Emergency", "Medic", "EMT", "0" } local emergency2 = { "Emergency", "Medic", "Nurse", "25" } local emergency3 = { "Emergency", "Medic", "Paramedic", "50" } local emergency4 = { "Emergency", "Medic", "Doctor", "75" } local emergency5 = { "Emergency", "Medic", "Surgeon", "100" } --outputChatBox ( criminal [ 1 ] ) -- bar --outputChatBox ( criminal [ 2 ] ) -- baz --outputChatBox ( criminal [ 3 ] ) -- anything function timer() setTimer(checkIfRankUp, "5000", 0) end function checkIfRankUp() local players = getElementsByType ( "player" ) for theKey,thePlayer in ipairs(players) do if ( thePlayer ) then if getElementData ( thePlayer, "Occupation" ) == "Criminal" then criminal(thePlayer) elseif getElementData ( thePlayer, "Occupation" ) == "Police" then police(thePlayer) elseif getElementData ( thePlayer, "Occupation" ) == "Trucker" then trucker(thePlayer) elseif getElementData ( thePlayer, "Occupation" ) == "Medic" then medic(thePlayer) elseif getElementData ( thePlayer, "Occupation" ) == "Freeroam" then freeroam(thePlayer) elseif getElementData ( thePlayer, "Occupation" ) == "Unemployed" then unemployed(thePlayer) else return end end end end function freeroam(thePlayer) setElementData(thePlayer, "Occupation", "Freeroam") setElementData(thePlayer, "Rank", "Insane") end function unemployed(thePlayer) setElementData(thePlayer, "Occupation", "Unemployed") setElementData(thePlayer, "Rank", "Unemployed") end function criminal(thePlayer) local crimActions = getElementData(thePlayer, "Criminal-actions" ) local occ = getElementData(thePlayer, "Occupation") if crimActions >= 99 and crimActions <= 199 then setElementData(thePlayer, "Rank", criminal2 [ 2 ] ) elseif crimActions >= 199 and crimActions <= 299 then setElementData(thePlayer, "Rank", criminal3 [ 2 ] ) elseif crimActions >= 299 and crimActions <= 499 then setElementData(thePlayer, "Rank", criminal4 [ 2 ] ) elseif crimActions >= 499 and crimActions <= 900 then setElementData(thePlayer, "Rank", criminal5 [ 2 ] ) elseif crimActions == 0 then setElementData(thePlayer, "Rank", criminal1 [ 2 ] ) end end function police(thePlayer) local polcActions = getElementData(thePlayer, "Police-actions" ) local occ = getElementData(thePlayer, "Occupation") if polcActions >= 99 and polcActions <= 199 then setElementData(thePlayer, "Rank", police2 [ 2 ] ) elseif polcActions >= 199 and polcActions <= 299 then setElementData(thePlayer, "Rank", police3 [ 2 ] ) elseif polcActions >= 299 and polcActions <= 499 then setElementData(thePlayer, "Rank", police4 [ 2 ] ) elseif polcActions >= 499 and polcActions <= 900 then setElementData(thePlayer, "Rank", police5 [ 2 ] ) elseif polcActions == 0 then setElementData(thePlayer, "Rank", police1 [ 2 ] ) end end function trucker(thePlayer) local trucActions = getElementData(thePlayer, "Trucker-actions" ) local occ = getElementData(thePlayer, "Occupation") if trucActions >= 0 and trucActions <= 49 then setElementData(thePlayer, "Rank", civilian2 [ 3 ] ) elseif trucActions>= 49 and trucActions <= 74 then setElementData(thePlayer, "Rank", civilian3 [ 3 ] ) elseif trucActions >= 74 and trucActions <= 99 then setElementData(thePlayer, "Rank", civilian4 [ 3 ] ) elseif trucActions >= 99 and trucActions <= 149 then setElementData(thePlayer, "Rank", civilian5 [ 3 ] ) elseif trucActions == 0 then setElementData(thePlayer, "Rank", civilian1 [ 3 ] ) end end function medic(thePlayer) local mediActions = getElementData(thePlayer, "Medic-actions" ) local occ = getElementData(thePlayer, "Occupation") if mediActions >= 0 and mediActions <= 24 then setElementData(thePlayer, "Rank", emergency2 [ 3 ] ) elseif mediActions>= 24 and mediActions <= 49 then setElementData(thePlayer, "Rank", emergency3 [ 3 ] ) elseif mediActions>= 49 and mediActions <= 74 then setElementData(thePlayer, "Rank", emergency4 [ 3 ] ) elseif mediActions >= 74 and mediActions <= 99 then setElementData(thePlayer, "Rank", emergency5 [ 3 ] ) elseif mediActions == 0 then setElementData(thePlayer, "Rank", emergency1 [ 3 ] ) end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), timer )
  22. Thank you, can you help me little make a some example how i can take information about tables. Example: local ranks = { {"Criminal", "Street Rat", 0}, {"Criminal", "Mugger", 100}, {"Police", "Trainee", 0}, {"Police", "Officer", 100} } ranks [ 1 ] -- {"Criminal", "Street Rat", 0} ranks [ 2 ] -- {"Criminal", "Mugger", 100} ranks [ 3 ] -- {"Police", "Trainee", 0} -- etc.. Note: This example should not be tested as it is just for clarifying how this works, and it will show an error as soon as you run it. Another example: local foo = { "bar", "baz", "anything" } outputChatBox ( foo [ 1 ] ) -- bar outputChatBox ( foo [ 2 ] ) -- baz outputChatBox ( foo [ 3 ] ) -- anything This is fine to be tested. Read more about Lua tables here: http://lua-users.org/wiki/TablesTutorial Thank you very much, now i have some idea how to working on it
  23. Thank you, can you help me little make a some example how i can take information about tables.
×
×
  • Create New...