BenceDev Posted March 17, 2022 Share Posted March 17, 2022 Hii, Again me! I have problem, so i wanna get player account from server side to client side, but it doesn't work. I got 1 error 1 warning: WARNING: exg_paintjob\exClient.lua:108 Bad argument v 'getElementData' [Expected element at argument 1, got nil] ERROR: exg_paintjob\exClient.lua:109: attempt to concatenate local 'plrAccName' (a boolean value) Server Side: function addVehiclePaintJob(veh, model, id) if id > 0 then triggerClientEvent(root, "addVehiclePaintJob", source, veh, model, id) else triggerClientEvent(root, "destroyShaderCache", source, veh) end end addEvent("addVehiclePaintJob", true) addEventHandler("addVehiclePaintJob", root, addVehiclePaintJob) addEventHandler("onPlayerLogin", getRootElement(), function(_, playerAccount) local accName = getAccountName(playerAccount) -- save the account name as data setElementData(source, "accName", accountName) end ) Client Side: availablePaintJobs = { [562] = { {'*remap2010f150*', 'textures/remap2010f150_1.png'}, {'*remap2010f150*', 'textures/remap2010f150_2.png'}, {'*remap2010f150*', 'textures/remap2010f150_3.png'}, }, }; local shaders = {} local elementShaders = {} local textureCache = {} local textureCount = {} local textureSize = 768 function applyShader(texture, img, distance, element) if element then destroyShaderCache(element) end local this = #shaders + 1 shaders[this] = {} shaders[this][1] = dxCreateShader("texturechanger.fx",0,distance,layered) if not textureCount[img] then textureCount[img] = 0 end if textureCount[img] == 0 then textureCache[img] = dxCreateTexture(img) end textureCount[img] = textureCount[img] + 1 shaders[this][2] = textureCache[img] shaders[this][3] = texture if element then if not elementShaders[element] then elementShaders[element] = {shaders[this], img} end end if shaders[this][1] and shaders[this][2] then dxSetShaderValue(shaders[this][1], "TEXTURE", shaders[this][2]) engineApplyShaderToWorldTexture(shaders[this][1], texture, element) end end function destroyShaderCache(element) if elementShaders[element] then destroyElement(elementShaders[element][1][1]) local old_img = elementShaders[element][2] textureCount[old_img] = textureCount[old_img] - 1 if textureCount[old_img] == 0 then destroyElement(elementShaders[element][1][2]) end elementShaders[element] = nil end end addEvent("destroyShaderCache", true) addEventHandler("destroyShaderCache", root, destroyShaderCache) addEventHandler("onClientResourceStart", resourceRoot, function() for k,v in ipairs(getElementsByType("vehicle", root, true)) do local pj = tonumber(getElementData(v, "tuning.paintjob")) or 0 if pj > 0 then addVehiclePaintJob(v, getElementModel(v), pj) end end end) function getVehiclePaintJobs(model) if availablePaintJobs[model] then return #availablePaintJobs[model] else return 0 end end function addVehiclePaintJob(veh, model, id) local pj = availablePaintJobs[model] if pj then local pj = pj[id] if pj then applyShader(pj[1], pj[2], 100, veh) end end end addEvent("addVehiclePaintJob", true) addEventHandler("addVehiclePaintJob", root, addVehiclePaintJob) addEventHandler("onClientElementDestroy", getRootElement(), function() if getElementType(source) == "vehicle" then destroyShaderCache(source) end end) addEventHandler("onClientElementStreamIn", getRootElement(), function() if getElementType(source) == "vehicle" then local pj = tonumber(getElementData(source, "tuning.paintjob")) or 0 if pj > 0 then addVehiclePaintJob(source, getElementModel(source), pj) end end end) addEventHandler("onClientElementStreamOut", getRootElement(), function() if getElementType(source) == "vehicle" then destroyShaderCache(source) end end) addCommandHandler("pj", function(cmd,id) local plrAccName = getElementData(thePlayer, 'accName') if isObjectInACLGroup("user."..plrAccName, aclGetGroup("Admin")) or isObjectInACLGroup("user."..plrAccName, aclGetGroup("Owner")) then local veh = getPedOccupiedVehicle(localPlayer) if veh then local id = tonumber(id) or 0 local model = getElementModel(veh) if availablePaintJobs[model] and availablePaintJobs[model][id] then setElementData(veh, "tuning.paintjob", id) triggerServerEvent("addVehiclePaintJob", localPlayer, veh, model, id, true) end end end end) What's the problem in my code? Link to comment
βurak Posted March 17, 2022 Share Posted March 17, 2022 (edited) Try changing thePlayer to localPlayer addCommandHandler("pj", function(cmd,id) local plrAccName = getElementData(localPlayer, 'accName') --change thePlayer to localPlayer if isObjectInACLGroup("user."..plrAccName, aclGetGroup("Admin")) or isObjectInACLGroup("user."..plrAccName, aclGetGroup("Owner")) then local veh = getPedOccupiedVehicle(localPlayer) if veh then local id = tonumber(id) or 0 local model = getElementModel(veh) if availablePaintJobs[model] and availablePaintJobs[model][id] then setElementData(veh, "tuning.paintjob", id) triggerServerEvent("addVehiclePaintJob", localPlayer, veh, model, id, true) end end end end) Edited March 17, 2022 by Burak5312 Link to comment
BenceDev Posted March 17, 2022 Author Share Posted March 17, 2022 7 minutes ago, Burak5312 said: Try changing thePlayer to localPlayer addCommandHandler("pj", function(cmd,id) local plrAccName = getElementData(localPlayer, 'accName') --change thePlayer to localPlayer if isObjectInACLGroup("user."..plrAccName, aclGetGroup("Admin")) or isObjectInACLGroup("user."..plrAccName, aclGetGroup("Owner")) then local veh = getPedOccupiedVehicle(localPlayer) if veh then local id = tonumber(id) or 0 local model = getElementModel(veh) if availablePaintJobs[model] and availablePaintJobs[model][id] then setElementData(veh, "tuning.paintjob", id) triggerServerEvent("addVehiclePaintJob", localPlayer, veh, model, id, true) end end end end) it doesn't work i got error: ERROR: exg_paintjob\exClient.lua: 109: attempt to concatenate local 'plrAccName' (a boolean value) Link to comment
βurak Posted March 17, 2022 Share Posted March 17, 2022 (edited) isObjectInACLGroup is server side function you can't use it on client side use triggerServerEvent and triggerClientEvent to do this split your code into pieces Edited March 17, 2022 by Burak5312 Link to comment
BenceDev Posted March 17, 2022 Author Share Posted March 17, 2022 oh, okay, nvrm, thx for help @Burak5312 Link to comment
BenceDev Posted March 17, 2022 Author Share Posted March 17, 2022 I again, so i have one more problem, if i try switch paintjob with command i got warning: Client side addCommandHandler("pj", function(cmd,id, source) local veh = getPedOccupiedVehicle(source) if veh then local id = tonumber(id) or 0 local model = getElementModel(veh) if availablePaintJobs[model] and availablePaintJobs[model][id] then setElementData(veh, "tuning.paintjob", id) triggerServerEvent("addVehiclePaintJob", localPlayer, veh, model, id, true) end end end) WARNING: exg_paintjob\exClient.lua:108: Bad argument @ 'getPedOccupiedVehicle' [Expected ped at argument 1, got nil] Link to comment
βurak Posted March 17, 2022 Share Posted March 17, 2022 change source to localPlayer addCommandHandler("pj", function(cmd,id) local veh = getPedOccupiedVehicle(localPlayer) --this if veh then local id = tonumber(id) or 0 local model = getElementModel(veh) if availablePaintJobs[model] and availablePaintJobs[model][id] then setElementData(veh, "tuning.paintjob", id) triggerServerEvent("addVehiclePaintJob", localPlayer, veh, model, id, true) end end end) Link to comment
BenceDev Posted March 17, 2022 Author Share Posted March 17, 2022 no debug error but the paintjob is not switch It Solved and work perfecly! Link to comment
βurak Posted March 17, 2022 Share Posted March 17, 2022 extra parameter is passed here can you try deleting the true part triggerServerEvent("addVehiclePaintJob", localPlayer, veh, model, id, true) -- <-- this triggerServerEvent("addVehiclePaintJob", localPlayer, veh, model, id) Link to comment
BenceDev Posted March 17, 2022 Author Share Posted March 17, 2022 OK, but now working fine, my mistake to i dont change .png files name Link to comment
βurak Posted March 17, 2022 Share Posted March 17, 2022 (edited) ok that's nice Edited March 17, 2022 by Burak5312 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now