Stealthy Serval

Members
  • Content Count

    16
  • Joined

  • Last visited

Community Reputation

3 Neutral

About Stealthy Serval

  • Rank
    Square
  • Birthday 03/03/1996

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Stealthy Serval

    Vehicles disappear on disconnect

    I still don't know what caused it, but I took your suggestion and commented out all dimensions, just to keep everything in the main dimension. (Initially the setElementDimension in my vehicle script was to bugcheck dimensions from my character system) It still didn't work, they kept disappearing so I called it for the night. I shut my server down, turned off my VPS, and let it be. Woke up today expecting to fix it again, booted up the VPS and the server, and no issues whatsoever. I'm beginning to think that my server hates me haha
  2. Stealthy Serval

    Vehicles disappear on disconnect

    Yeah, so I've gone through all resources and I have nothing telling the vehicles to destroy on disconnect, connect, or anything like that. For safety measures I've even commented out my /destroyvehicle command, and even commented out all instances of "onPlayerQuit", yet the vehicles still disappear when you disconnect.
  3. Stealthy Serval

    Vehicles disappear on disconnect

    I've currently made it so my vehicles spawn from my database, which works fine. But as soon as I disconnect, all vehicles are no longer spawned and I have to restart the resource to respawn them. function resourceStart() local allVehicles = sql:query("SELECT * FROM vehicles") for i,v in ipairs(allVehicles)do local theVeh = createVehicle(v["model"],v["posx"],v["posy"],v["posz"],v["posrx"],v["posry"],v["posrz"],v["tag"]) if not theVeh then return end setElementDimension(theVeh,0) setElementData(theVeh,"id",v["id"]) setVehicleColor(theVeh,v["color1"],v["color2"],v["color3"],v["color4"],v["color5"],v["color6"]) setElementData(theVeh,"ownerID",v["ownerid"]) setElementData(theVeh,"faction",v["faction"]) setElementData(theVeh,"isLocked",v["isLocked"]) if(v["isLocked"] == 0)then setVehicleLocked(theVeh,false) else setVehicleLocked(theVeh,true) end setVehicleOverrideLights(theVeh,v["lightState"]) setElementData(theVeh,"lightState",v["lightState"]) setElementData(theVeh,"engineState",v["engineState"]) if(v["engineState"] == "true")then setVehicleEngineState(theVeh,true) elseif(v["engineState"] == "false")then setVehicleEngineState(theVeh,false) end if (v["hasSirens"] == 1) then addVehicleSirens(theVeh,1,2) setElementData(theVeh,"sirens",true) else setElementData(theVeh,"sirens",false) end end end addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),resourceStart) I don't have any calls anywhere to destroy the vehicles on disconnect, only a /destroyvehicle command which only deletes vehicles that match the owner.
  4. Stealthy Serval

    setPedAnimation not working with createPed

    Hey! So I did try that before posting, I used 500 initially for the time, and it didn't work, but for some reason using your 100 works. Any idea why this could be so I can avoid it later?
  5. Stealthy Serval

    setPedAnimation not working with createPed

    Hey all, I'm trying to make it so when a player loads in it creates a ped of their character and sets an animation. Before, when I did this with the player rather than the ped, it worked, but was a little spotty (sometimes it applied the animation, sometimes you had to reconnect for it to work) so I thought using a ped would be better. But the animation isn't applying at all. I've tried adding a timer, and all that did was make the ped spawn later, still no animation. The ped is being brought to the appropriate dimension, and spawning properly. charPed[1] = createPed(getElementData(player,"char1skin"),1187,-2034.4,69.007,180) setElementDimension(charPed[1],getElementDimension(player)) setPedAnimation(charPed[1],"ped","seat_idle",-1,false) Again, it worked properly with the player, just not now. Any help would be appreciated!
  6. Stealthy Serval

    setVehiclePlateText partially works

    Well, I don't know what happened, I didn't change anything, and it just randomly started working..🤔
  7. Stealthy Serval

    setVehiclePlateText partially works

    I currently have a command to spawn a vehicle using either the model ID or the vehicle name, and when you spawn the vehicle, it assigns a random plate to the vehicle. This works perfectly if you use the vehicle model ID, but if you use the name (ie "Tampa") it returns an error: WANRING: vehicle-system\vs_server.lua:184: Bad argument @ 'setVehiclePlateText' [Expected string at argument 2, got nil] I've moved my variables around, called the function in and out of the different sections of code, but still don't understand why it's doing this. Here is my command: --Create Vehicle/Spawn Vehicle from ID or name function commandCreateVehicle(thePlayer,command,vehicleModel) if(vehicleModel)then local vehicleToSpawn = tonumber(vehicleModel) local vehicleOwner = getPlayerName(thePlayer) local vehTag = createRandomPlateText() local x,y,z = getElementPosition(thePlayer) x = x+5 z = z+2 if(vehicleToSpawn ~= nil)then if(vehicleToSpawn > 399)then if(vehicleToSpawn < 612)then local theVehicle = createVehicle(vehicleToSpawn,x,y,z) if(theVehicle)then local vehicleName = getVehicleNameFromModel(vehicleToSpawn) vehicleTag = vehicleTag + 1 setElementData(theVehicle,"name",vehicleName) setElementData(theVehicle,"model",vehicleToSpawn) setElementData(theVehicle,"tag",vehTag) setElementData(theVehicle,"id",vehicleTag) setVehicleOverrideLights(theVehicle,1) setVehiclePlateText(theVehicle,vehTag) setElementData(theVehicle,"owner",vehicleOwner) outputChatBox("(#"..vehicleTag..") Enjoy your "..vehicleName..", "..getPlayerName(thePlayer).."!",thePlayer,0,255,0) else outputChatBox("Vehicle failed to spawn. Error: SM01.",thePlayer,255,0,0) end else outputChatBox("Invalid vehicle ID.",thePlayer,255,0,0) end else outputChatBox("Invalid vehicle ID.",thePlayer,255,0,0) end else local theVehicle = createVehicle(getVehicleModelFromName(vehicleModel),x,y,z) if(theVehicle)then local vehicleID = getVehicleModelFromName(vehicleModel) local vehicleName = getVehicleNameFromModel(vehicleID) vehicleTag = vehicleTag + 1 setElementData(theVehicle,"name",vehicleName) setElementData(theVehicle,"model",vehicleID) setElementData(theVehicle,"tag",vehTag) setElementData(theVehicle,"id",vehicleTag) setVehiclePlateText(theVehicle,vehTag) setElementData(theVehicle,"owner",vehicleOwner) setVehicleOverrideLights(theVehicle,1) outputChatBox("(#"..vehicleTag..") Enjoy your "..vehicleName..", "..getPlayerName(thePlayer).."!",thePlayer,0,255,0) else outputChatBox("Invalid vehicle name.",thePlayer,255,0,0) end end else outputChatBox("Invalid syntax. Please use: /createvehicle [vehicle ID/name]",thePlayer,255,0,0) end end addCommandHandler("createvehicle",commandCreateVehicle) addCommandHandler("cv",commandCreateVehicle) and here is the createRandomPlateText() function local characters = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"} function createRandomPlateText() local plate = "" for i = 1, 3 do plate = plate..characters[math.random(1, #characters)] end plate = plate.."-" for i = 1, 3 do plate = plate..math.random(1, 9) end qh = sql:query("SELECT * FROM vehicles WHERE tag=?",plate) local row = qh[1] if row then createRandomPlateText() else return plate end end
  8. Stealthy Serval

    string.match only looking at first character

    I was able to fix this problem by adding "+$" to the end of the string.find() calls. if not string.find(fName, "^%a+$") or not string.find(lName,"^%a+$")then if isTimer(cTimer)then killTimer(cTimer) end guiSetText(createChar.errorLab,"Invalid characters. (A-Z only)") cTimer = setTimer(fadeError,3000,1) return end I'm not sure if this is the most effective way or not, but it fixed it!
  9. Stealthy Serval

    string.match only looking at first character

    Hey all, so I'm wanting to look at the string from a characters name and ensure that all characters are A-Z (no numbers or special characters) But unfortunately I can only get it to look at the first character of the string. if not string.find(fName, "^%a") or not string.find(lName,"^%a")then if isTimer(cTimer)then killTimer(cTimer) end guiSetText(createChar.errorLab,"Invalid characters. (A-Z only)") cTimer = setTimer(fadeError,3000,1) return end I've switched between string.find() and string.match() to try them both, and I've also switched the code from if not to if and else, but still not luck.
  10. EDIT: I have realized I am an idiot, and discovered the "setTrafficLightsLocked" function. Problem solved. END EDIT Hey all, so I was attempting to make it so the lights updated at an almost realistic time. After 20 seconds of being green, I want them to turn yellow, after 6 seconds yellow, turn red, 1 second of red, turn back to green but for the other direction, and so on and so forth. Unfortunately this has just resulted in chaos, the lights are not updating even within the 20 seconds and after about 30 seconds or so they just start flashing like crazy. greenTime = 20000 yellowTime = 6000 redTime = 1000 gTimer = nil yTimer = nil rTimer = nil lState = nil function startTrafficLights() setTrafficLightState(0) lState = 0 gTimer = setTimer(updateLights,greenTime,1) end addEventHandler("onResourceStart",getRootElement(getThisResource()),startTrafficLights) function updateLights() if(lState == 0)then setTrafficLightState(1) killTimer(gTimer) lState = 1 yTimer = setTimer(updateLights,yellowTime,1) elseif(lState == 1)then setTrafficLightState(2) killTimer(yTimer) lState = 2 rTimer = setTimer(updateLights,redTime,1) elseif(lState == 2)then setTrafficLightState(3) killTimer(rTimer) lState = 3 gTimer = setTimer(updateLights,greenTime,1) elseif(lState == 3)then setTrafficLightState(4) killTimer(gTimer) lState = 4 yTimer = setTimer(updateLights,yellowTime,1) elseif(lState == 4)then setTrafficLightState(2) killTimer(yTimer) lState = 5 rTimer = setTimer(updateLights,redTime,1) elseif(lState == 5)then setTrafficLightState(0) killTimer(rTimer) lState = 0 gTimer = setTimer(updateLights,greenTime,1) end end I'm unsure what could be causing this, or even if I'm approaching this correctly. Any help is always appreciated! EDIT: I added in debugstrings to each timer section, and it is calling the debugstring accordingly, but the traffic light states are not holding.
  11. Stealthy Serval

    triggerClientEvent does nothing

    Hey all, thanks for the replies. So, I ended up migrating a bit of it serverside, and changing it up clientside. If anyone has any general feedback on my code, or anything they see that makes them really question why the heck I did things a certain way, please feel free to share as I am still very very new to Lua and programming in general. Server-side script: sql = exports["sql-system"] function characterMain() charCount = 0 character = {} character[1] = {} character[2] = {} character[3] = {} allAccountQuery = sql:query("SELECT * FROM characters") selectedID = 0 for i,c in ipairs(allAccountQuery)do selectedID = selectedID+1 userCharacterQuery = sql:query("SELECT * FROM characters WHERE id=?",selectedID) characters = userCharacterQuery[1] if characters then if(characters.account == getElementData(source,"getPlayerUsername"))then charCount = charCount+1 if(charCount == 1)then character[1].skin = characters.skin character[1].name = characters.name character[1].cash = characters.cash character[1].bank = characters.bank character[1].valid = true elseif(charCount == 2)then character[2].skin = characters.skin character[2].name = characters.name character[2].cash = characters.cash character[2].bank = characters.bank character[2].valid = true elseif(charCount == 3)then character[3].skin = characters.skin character[3].name = characters.name character[3].cash = characters.cash character[3].bank = characters.bank character[3].valid = true end end end end if(character[1].valid == true)then setElementData(source,"char1skin",character[1].skin) setElementData(source,"char1name",character[1].name) setElementData(source,"char1bank",character[1].bank) setElementData(source,"char1cash",character[1].cash) end if(character[2].valid == true)then setElementData(source,"char2skin",character[2].skin) setElementData(source,"char2name",character[2].name) setElementData(source,"char2bank",character[2].bank) setElementData(source,"char2cash",character[2].cash) end if(character[3].valid == true)then setElementData(source,"char3skin",character[3].skin) setElementData(source,"char3name",character[3].name) setElementData(source,"char3bank",character[3].bank) setElementData(source,"char3cash",character[3].cash) end triggerClientEvent(source,"showCharacters",resourceRoot,source,charCount) end addEvent("character.main",true) addEventHandler("character.main",getRootElement(),characterMain) and the Client-Side script: characterWindow = {} characterWindow.character = {} characterWindow.characterName = {} characterWindow.characterCash = {} characterWindow.characterBank = {} characterWindow.characterButton = {} characterWindow.deleteCharacterButton = {} function showCharacters(player, characterCount) local screenW, screenH = guiGetScreenSize() characterWindow.window = guiCreateWindow(10, (screenH - 391) / 2, 272, 391, "Select character image to continue", false) guiWindowSetSizable(characterWindow.window, false) characterWindow.accountLogout = guiCreateButton(10, 366, 85, 15, "Logout", false, characterWindow.window) guiSetProperty(characterWindow.accountLogout, "NormalTextColour", "FFAAAAAA") characterWindow.accountDisconnect = guiCreateButton(174, 367, 85, 14, "Disconnect", false, characterWindow.window) guiSetProperty(characterWindow.accountDisconnect, "NormalTextColour", "FFAAAAAA") --First Character, position for subsequent characters is +60 if(characterCount == 0)then --[[CREATE CHARACTER]] characterWindow.newChar = guiCreateStaticImage(10, 29, 55, 50, ":character-system/images/create-char.png", false, characterWindow.window) characterWindow.newCharLabel = guiCreateLabel(75, 32, 155, 15, "Create New Character", false, characterWindow.window) characterWindow.newCharSlots = guiCreateLabel(75, 62, 155, 15, "3 Character Slots Remaining", false, characterWindow.window) characterWindow.newCharButton = guiCreateButton(10, 28, 252, 52, "", false, characterWindow.window) guiSetAlpha(characterWindow.newCharButton, 0.00) guiSetProperty(characterWindow.newCharButton, "Alpha", "0.000000") guiSetProperty(characterWindow.newCharButton, "NormalTextColour", "FFAAAAAA") guiSetVisible(characterWindow.window,true) elseif(characterCount == 1)then --[[CHARACTER #1]] characterWindow.character[1] = guiCreateStaticImage(10, 29, 55, 50, ":character-system/images/chars/"..getElementData(player,"char1skin")..".png", false, characterWindow.window) characterWindow.characterName[1] = guiCreateLabel(75, 32, 119, 15, getElementData(player,"char1name"), false, characterWindow.window) characterWindow.characterCash[1] = guiCreateLabel(75, 47, 119, 15, "Cash: $"..getElementData(player,"char1cash"), false, characterWindow.window) characterWindow.characterBank[1] = guiCreateLabel(75, 62, 119, 15, "Bank: $"..getElementData(player,"char1bank"), false, characterWindow.window) characterWindow.deleteCharacter = guiCreateStaticImage(204, 29, 55, 50, ":character-system/images/delete-char.png", false, characterWindow.window) characterWindow.characterButton[1] = guiCreateButton(10, 28, 192, 52, "", false, characterWindow.window) characterWindow.deleteCharacterButton[1] = guiCreateButton(202, 28, 60, 52, "", false, characterWindow.window) guiSetAlpha(characterWindow.characterButton[1], 0.00) guiSetProperty(characterWindow.characterButton[1], "Alpha", "0.000000") guiSetAlpha(characterWindow.deleteCharacterButton[1], 0.00) guiSetProperty(characterWindow.deleteCharacterButton[1], "Alpha", "0.000000") guiSetProperty(characterWindow.characterButton[1], "NormalTextColour", "FFAAAAAA") addEventHandler("onClientGUIClick",characterWindow.characterButton[1],selectCharacter,false) addEventHandler("onClientGUIClick",characterWindow.deleteCharacterButton[1],deleteCharacter,false) --[[CREATE CHARACTER]] characterWindow.newChar = guiCreateStaticImage(10, 89, 55, 50, ":character-system/images/create-char.png", false, characterWindow.window) characterWindow.newCharLabel = guiCreateLabel(75, 92, 155, 15, "Create New Character", false, characterWindow.window) characterWindow.newCharSlots = guiCreateLabel(75, 122, 155, 15, "2 Character Slots Remaining", false, characterWindow.window) characterWindow.newCharButton = guiCreateButton(10, 88, 252, 52, "", false, characterWindow.window) guiSetAlpha(characterWindow.newCharButton, 0.00) guiSetProperty(characterWindow.newCharButton, "Alpha", "0.000000") guiSetProperty(characterWindow.newCharButton, "NormalTextColour", "FFAAAAAA") addEventHandler("onClientGUIClick",characterWindow.newCharButton,createCharacter,false) guiSetVisible(characterWindow.window,true) elseif(characterCount == 2)then --[[CHARACTER #1]] characterWindow.character[1] = guiCreateStaticImage(10, 29, 55, 50, ":character-system/images/chars/"..getElementData(player,"char1skin")..".png", false, characterWindow.window) characterWindow.characterName[1] = guiCreateLabel(75, 32, 119, 15, getElementData(player,"char1name"), false, characterWindow.window) characterWindow.characterCash[1] = guiCreateLabel(75, 47, 119, 15, "Cash: $"..getElementData(player,"char1cash"), false, characterWindow.window) characterWindow.characterBank[1] = guiCreateLabel(75, 62, 119, 15, "Bank: $"..getElementData(player,"char1bank"), false, characterWindow.window) characterWindow.deleteCharacter = guiCreateStaticImage(204, 29, 55, 50, ":character-system/images/delete-char.png", false, characterWindow.window) characterWindow.characterButton[1] = guiCreateButton(10, 28, 192, 52, "", false, characterWindow.window) characterWindow.deleteCharacterButton[1] = guiCreateButton(202, 28, 60, 52, "", false, characterWindow.window) guiSetAlpha(characterWindow.characterButton[1], 0.00) guiSetProperty(characterWindow.characterButton[1], "Alpha", "0.000000") guiSetAlpha(characterWindow.deleteCharacterButton[1], 0.00) guiSetProperty(characterWindow.deleteCharacterButton[1], "Alpha", "0.000000") guiSetProperty(characterWindow.characterButton[1], "NormalTextColour", "FFAAAAAA") guiSetProperty(characterWindow.deleteCharacterButton[1], "NormalTextColour", "FFAAAAAA") addEventHandler("onClientGUIClick",characterWindow.characterButton[1],selectCharacter,false) addEventHandler("onClientGUIClick",characterWindow.deleteCharacterButton[1],deleteCharacter,false) --[[CHARACTER #2]] characterWindow.character[2] = guiCreateStaticImage(10, 89, 55, 50, ":character-system/images/chars/"..getElementData(player,"char2skin")..".png", false, characterWindow.window) characterWindow.characterName[2] = guiCreateLabel(75, 92, 119, 15, getElementData(player,"char2name"), false, characterWindow.window) characterWindow.characterCash[2] = guiCreateLabel(75, 107, 119, 15, "Cash: $"..getElementData(player,"char2cash"), false, characterWindow.window) characterWindow.characterBank[2] = guiCreateLabel(75, 122, 119, 15, "Bank: $"..getElementData(player,"char2bank"), false, characterWindow.window) characterWindow.deleteCharacter = guiCreateStaticImage(204, 89, 55, 50, ":character-system/images/delete-char.png", false, characterWindow.window) characterWindow.characterButton[2] = guiCreateButton(10, 88, 192, 52, "", false, characterWindow.window) characterWindow.deleteCharacterButton[2] = guiCreateButton(202, 88, 60, 52, "", false, characterWindow.window) guiSetAlpha(characterWindow.characterButton[2], 0.00) guiSetProperty(characterWindow.characterButton[2], "Alpha", "0.000000") guiSetAlpha(characterWindow.deleteCharacterButton[2], 0.00) guiSetProperty(characterWindow.deleteCharacterButton[2], "Alpha", "0.000000") guiSetProperty(characterWindow.characterButton[2], "NormalTextColour", "FFAAAAAA") guiSetProperty(characterWindow.deleteCharacterButton[2], "NormalTextColour", "FFAAAAAA") addEventHandler("onClientGUIClick",characterWindow.characterButton[2],selectCharacter,false) addEventHandler("onClientGUIClick",characterWindow.deleteCharacterButton[2],deleteCharacter,false) --[[CREATE CHARACTER]] characterWindow.newChar = guiCreateStaticImage(10, 149, 55, 50, ":character-system/images/create-char.png", false, characterWindow.window) characterWindow.newCharLabel = guiCreateLabel(75, 152, 155, 15, "Create New Character", false, characterWindow.window) characterWindow.newCharSlots = guiCreateLabel(75, 182, 155, 15, "1 Character Slot Remaining", false, characterWindow.window) characterWindow.newCharButton = guiCreateButton(10, 148, 252, 52, "", false, characterWindow.window) guiSetAlpha(characterWindow.newCharButton, 0.00) guiSetProperty(characterWindow.newCharButton, "Alpha", "0.000000") guiSetProperty(characterWindow.newCharButton, "NormalTextColour", "FFAAAAAA") addEventHandler("onClientGUIClick",characterWindow.newCharButton,createCharacter,false) guiSetVisible(characterWindow.window,true) elseif(characterCount == 3)then --[[CHARACTER #1]] characterWindow.character[1] = guiCreateStaticImage(10, 29, 55, 50, ":character-system/images/chars/"..getElementData(player,"char1skin")..".png", false, characterWindow.window) characterWindow.characterName[1] = guiCreateLabel(75, 32, 119, 15, getElementData(player,"char1name"), false, characterWindow.window) characterWindow.characterCash[1] = guiCreateLabel(75, 47, 119, 15, "Cash: $"..getElementData(player,"char1cash"), false, characterWindow.window) characterWindow.characterBank[1] = guiCreateLabel(75, 62, 119, 15, "Bank: $"..getElementData(player,"char1bank"), false, characterWindow.window) characterWindow.deleteCharacter = guiCreateStaticImage(204, 29, 55, 50, ":character-system/images/delete-char.png", false, characterWindow.window) characterWindow.characterButton[1] = guiCreateButton(10, 28, 192, 52, "", false, characterWindow.window) characterWindow.deleteCharacterButton[1] = guiCreateButton(202, 28, 60, 52, "", false, characterWindow.window) guiSetAlpha(characterWindow.characterButton[1], 0.00) guiSetProperty(characterWindow.characterButton[1], "Alpha", "0.000000") guiSetAlpha(characterWindow.deleteCharacterButton[1], 0.00) guiSetProperty(characterWindow.deleteCharacterButton[1], "Alpha", "0.000000") guiSetProperty(characterWindow.characterButton[1], "NormalTextColour", "FFAAAAAA") guiSetProperty(characterWindow.deleteCharacterButton[1], "NormalTextColour", "FFAAAAAA") addEventHandler("onClientGUIClick",characterWindow.characterButton[1],selectCharacter,false) addEventHandler("onClientGUIClick",characterWindow.deleteCharacterButton[1],deleteCharacter,false) --[[CHARACTER #2]] characterWindow.character[2] = guiCreateStaticImage(10, 89, 55, 50, ":character-system/images/chars/"..getElementData(player,"char2skin")..".png", false, characterWindow.window) characterWindow.characterName[2] = guiCreateLabel(75, 92, 119, 15, getElementData(player,"char2name"), false, characterWindow.window) characterWindow.characterCash[2] = guiCreateLabel(75, 107, 119, 15, "Cash: $"..getElementData(player,"char2cash"), false, characterWindow.window) characterWindow.characterBank[2] = guiCreateLabel(75, 122, 119, 15, "Bank: $"..getElementData(player,"char2bank"), false, characterWindow.window) characterWindow.deleteCharacter = guiCreateStaticImage(204, 89, 55, 50, ":character-system/images/delete-char.png", false, characterWindow.window) characterWindow.characterButton[2] = guiCreateButton(10, 88, 192, 52, "", false, characterWindow.window) characterWindow.deleteCharacterButton[2] = guiCreateButton(202, 88, 60, 52, "", false, characterWindow.window) guiSetAlpha(characterWindow.characterButton[2], 0.00) guiSetProperty(characterWindow.characterButton[2], "Alpha", "0.000000") guiSetAlpha(characterWindow.deleteCharacterButton[2], 0.00) guiSetProperty(characterWindow.deleteCharacterButton[2], "Alpha", "0.000000") guiSetProperty(characterWindow.characterButton[2], "NormalTextColour", "FFAAAAAA") guiSetProperty(characterWindow.deleteCharacterButton[2], "NormalTextColour", "FFAAAAAA") addEventHandler("onClientGUIClick",characterWindow.characterButton[2],selectCharacter,false) addEventHandler("onClientGUIClick",characterWindow.deleteCharacterButton[2],deleteCharacter,false) --[[CHARACTER #3]] characterWindow.character[3] = guiCreateStaticImage(10, 149, 55, 50, ":character-system/images/chars/"..getElementData(player,"char3skin")..".png", false, characterWindow.window) characterWindow.characterName[3] = guiCreateLabel(75, 152, 119, 15, getElementData(player,"char3name"), false, characterWindow.window) characterWindow.characterCash[3] = guiCreateLabel(75, 167, 119, 15, "Cash: $"..getElementData(player,"char3cash"), false, characterWindow.window) characterWindow.characterBank[3] = guiCreateLabel(75, 182, 119, 15, "Bank: $"..getElementData(player,"char3bank"), false, characterWindow.window) characterWindow.deleteCharacter = guiCreateStaticImage(204, 149, 55, 50, ":character-system/images/delete-char.png", false, characterWindow.window) characterWindow.characterButton[3] = guiCreateButton(10, 148, 192, 52, "", false, characterWindow.window) characterWindow.deleteCharacterButton[3] = guiCreateButton(202, 148, 60, 52, "", false, characterWindow.window) guiSetAlpha(characterWindow.characterButton[3], 0.00) guiSetProperty(characterWindow.characterButton[3], "Alpha", "0.000000") guiSetAlpha(characterWindow.deleteCharacterButton[3], 0.00) guiSetProperty(characterWindow.deleteCharacterButton[3], "Alpha", "0.000000") guiSetProperty(characterWindow.characterButton[3], "NormalTextColour", "FFAAAAAA") guiSetProperty(characterWindow.deleteCharacterButton[3], "NormalTextColour", "FFAAAAAA") addEventHandler("onClientGUIClick",characterWindow.characterButton[3],selectCharacter,false) addEventHandler("onClientGUIClick",characterWindow.deleteCharacterButton[3],deleteCharacter,false) guiSetVisible(characterWindow.window,true) end end addEvent("showCharacters",true) addEventHandler("showCharacters",getRootElement(),showCharacters)
  12. Stealthy Serval

    triggerClientEvent does nothing

    So, the issue actually was that I forgot you can't call SQL functions client-side. So I've got to find a way to migrate the bulk of that data server-side. Any tips? lol
  13. Stealthy Serval

    triggerClientEvent does nothing

    EDIT: I realize now the issue is that I am calling SQL functions client-side. Any tips on how to migrate the majority of that client-side script server-side? END EDIT I'm trying to make it so when the player signs in, it will count how many characters they have, and create a GUI based on that. But I can not get my script to talk to my clientside event, no matter what I try. Any help on this would be appreciated! Server-Side Script: function characterMain() charCount = 0 acq = sql:query("SELECT * FROM characters") for i,c in ipairs(acq)do cq = sql:query("SELECT * FROM characters WHERE account=?",getElementData(source,"getPlayerUsername")) characters = cq[1] if characters then charCount = charCount+1 end end outputDebugString("Account: "..getElementData(source,"getPlayerUsername").." has "..charCount.." character(s).") triggerClientEvent(source,"showCharacters",source,source,charCount) --return charCount end addEvent("character.main",true) addEventHandler("character.main",getRootElement(),characterMain) Client-Side Script (It's lengthy): function showCharacters(player, characterCount) local loopCount = 0 local character = {} character[1] = {} character[2] = {} character[3] = {} acq = sql:query("SELECT * FROM characters WHERE account=?",getElementData(source,"getPlayerUsername")) for i,c in ipairs(acq)do if(characterCount == 1)then if(loopCount == 0)then character[1].skin = tonumber(c.skin) character[1].name = c.name character[1].cash = c.cash character[1].bank = c.bank loopCount = loopCount+1 end elseif(characterCount == 2)then if(loopCount == 0)then character[1].skin = tonumber(c.skin) character[1].name = c.name character[1].cash = c.cash character[1].bank = c.bank loopCount = loopCount+1 elseif(loopCount == 1)then character[2].skin = tonumber(c.skin) character[2].name = c.name character[2].cash = c.cash character[2].bank = c.bank loopCount = loopCount+1 end elseif(characterCount == 3)then if(loopCount == 0)then character[1].skin = tonumber(c.skin) character[1].name = c.name character[1].cash = c.cash character[1].bank = c.bank loopCount = loopCount+1 elseif(loopCount == 1)then character[2].skin = tonumber(c.skin) character[2].name = c.name character[2].cash = c.cash character[2].bank = c.bank loopCount = loopCount+1 elseif(loopCount == 2)then character[3].skin = tonumber(c.skin) character[3].name = c.name character[3].cash = c.cash character[3].bank = c.bank loopCount = loopCount+1 end end end local screenW, screenH = guiGetScreenSize() characterWindow.window = guiCreateWindow(10, (screenH - 391) / 2, 272, 391, "Select character image to continue", false) guiWindowSetSizable(characterWindow.window, false) characterWindow.accountLogout = guiCreateButton(10, 366, 85, 15, "Logout", false, characterWindow.window) guiSetProperty(characterWindow.accountLogout, "NormalTextColour", "FFAAAAAA") characterWindow.accountDisconnect = guiCreateButton(174, 367, 85, 14, "Disconnect", false, characterWindow.window) guiSetProperty(characterWindow.button[2], "NormalTextColour", "FFAAAAAA") --First Character, position for subsequent characters is +60 if(characterCount == 1)then --[[CHARACTER #1]] characterSelection.character[1] = guiCreateStaticImage(10, 29, 55, 50, ":character-system/images/chars/"..character[1].skin..".png", false, characterWindow.window) characterWindow.characterName[1] = guiCreateLabel(75, 32, 119, 15, character[1].name, false, characterWindow.window) characterWindow.characterCash[1] = guiCreateLabel(75, 47, 119, 15, character[1].cash, false, characterWindow.window) characterWindow.characterBank[1] = guiCreateLabel(75, 62, 119, 15, character[1].bank, false, characterWindow.window) characterWindow.deleteCharacter = guiCreateStaticImage(204, 29, 55, 50, ":character-system/images/delete-char.png", false, characterWindow.window) guiSetVisible(characterWindow.window,true) elseif(characterCount == 2)then --[[CHARACTER #1]] characterSelection.character[1] = guiCreateStaticImage(10, 29, 55, 50, ":character-system/images/chars/"..character[1].skin..".png", false, characterWindow.window) characterWindow.characterName[1] = guiCreateLabel(75, 32, 119, 15, character[1].name, false, characterWindow.window) characterWindow.characterCash[1] = guiCreateLabel(75, 47, 119, 15, character[1].cash, false, characterWindow.window) characterWindow.characterBank[1] = guiCreateLabel(75, 62, 119, 15, character[1].bank, false, characterWindow.window) characterWindow.deleteCharacter = guiCreateStaticImage(204, 29, 55, 50, ":character-system/images/delete-char.png", false, characterWindow.window) --[[CHARACTER #2]] characterSelection.character[2] = guiCreateStaticImage(10, 89, 55, 50, ":character-system/images/chars/"..character[2].skin..".png", false, characterWindow.window) characterWindow.characterName[2] = guiCreateLabel(75, 92, 119, 15, character[2].name, false, characterWindow.window) characterWindow.characterCash[2] = guiCreateLabel(75, 107, 119, 15, character[2].cash, false, characterWindow.window) characterWindow.characterBank[2] = guiCreateLabel(75, 122, 119, 15, character[2].bank, false, characterWindow.window) characterWindow.deleteCharacter = guiCreateStaticImage(204, 89, 55, 50, ":character-system/images/delete-char.png", false, characterWindow.window) guiSetVisible(characterWindow.window,true) elseif(characterCount == 3)then --[[CHARACTER #1]] characterSelection.character[1] = guiCreateStaticImage(10, 29, 55, 50, ":character-system/images/chars/"..character[1].skin..".png", false, characterWindow.window) characterWindow.characterName[1] = guiCreateLabel(75, 32, 119, 15, character[1].name, false, characterWindow.window) characterWindow.characterCash[1] = guiCreateLabel(75, 47, 119, 15, character[1].cash, false, characterWindow.window) characterWindow.characterBank[1] = guiCreateLabel(75, 62, 119, 15, character[1].bank, false, characterWindow.window) characterWindow.deleteCharacter = guiCreateStaticImage(204, 29, 55, 50, ":character-system/images/delete-char.png", false, characterWindow.window) --[[CHARACTER #2]] characterSelection.character[2] = guiCreateStaticImage(10, 89, 55, 50, ":character-system/images/chars/"..character[2].skin..".png", false, characterWindow.window) characterWindow.characterName[2] = guiCreateLabel(75, 92, 119, 15, character[2].name, false, characterWindow.window) characterWindow.characterCash[2] = guiCreateLabel(75, 107, 119, 15, character[2].cash, false, characterWindow.window) characterWindow.characterBank[2] = guiCreateLabel(75, 122, 119, 15, character[2].bank, false, characterWindow.window) characterWindow.deleteCharacter = guiCreateStaticImage(204, 89, 55, 50, ":character-system/images/delete-char.png", false, characterWindow.window) --[[CHARACTER #3]] characterSelection.character[3] = guiCreateStaticImage(10, 149, 55, 50, ":character-system/images/chars/"..character[3].skin..".png", false, characterWindow.window) characterWindow.characterName[3] = guiCreateLabel(75, 152, 119, 15, character[3].name, false, characterWindow.window) characterWindow.characterCash[3] = guiCreateLabel(75, 167, 119, 15, character[3].cash, false, characterWindow.window) characterWindow.characterBank[3] = guiCreateLabel(75, 182, 119, 15, character[3].bank, false, characterWindow.window) characterWindow.deleteCharacter = guiCreateStaticImage(204, 149, 55, 50, ":character-system/images/delete-char.png", false, characterWindow.window) guiSetVisible(characterWindow.window,true) else outputDebugString("It worked, finally.") guiSetVisible(characterWindow.window,false) end end addEvent("showCharacters",true) addEventHandler("showCharacters",getRootElement(),showCharacters) The server-side function is working, and will return to the server "Account has X characters" correctly, but will not trigger the client-side event.
  14. Stealthy Serval

    [SOLVED] Generate random license plate text on vehicle creation

    It does need to be unique, but I actually have a check in place for that! That works perfectly, thank you so much. I clearly need to learn more Lua because I really don't understand the whole "for do" statements.
  15. Hey all, so I'm struggling trying to understand how I could create a random license plate when a vehicle spawns. I got it down to generate random numbers, but I was hoping to have the license plate be 3 characters followed by 3 numbers. How would I go about getting this done?