-
Posts
605 -
Joined
-
Last visited
-
Days Won
1
Everything posted by JeViCo
-
Hello everyone! Here is my code: addEventHandler("onResourceStart", resourceRoot, function() db = dbConnect("sqlite", "credits.db") db2 = dbConnect("sqlite", ":salo/database.db") --dbExec(db, "TRUNCATE TABLE CreditList") -- очистка dbExec(db, "CREATE TABLE IF NOT EXISTS CreditList (Player, Type, Amount, TimeLeft)") end ) --[[ addEventHandler("onResourceStop",resourceRoot, function() end )]] addEventHandler("onPlayerQuit",getRootElement(),function() if getElementData(source,"isCredit") and getElementData(source,"CreditAmount") then dbExec(db,"UPDATE CreditList SET Amount = ?, TimeLeft = ? WHERE Player = ?",getElementData(source,"CreditAmount"),getTimerDetails(timers[source]),getAccountName(getPlayerAccount(source))) killTimer(timers[source]) end end) --[[ addCommandHandler("hel",function(localplayer) setElementData(localplayer,"isCredit",false) setElementData(localplayer,"CreditAmount",0) end)]] addEventHandler("onPlayerLogin",getRootElement(),function() --setTimer( --function(source) local acc = getPlayerAccount(source) if getAccountData(acc,"isCredit") then dat = dbPoll(dbQuery(db, "SELECT * FROM CreditList WHERE Player = ?", getAccountName(getPlayerAccount(source))), -1) givecr(source,dat["Type"],dat["Amount"],dat["TimeLeft"]) dat = nil end acc = nil setElementData(source,"creditMultiplier",credit_) setElementData(source,"depositMultiplier",deposit_) --end,50,1) end) function givecr(player_,type_,amount,timeleft_timer) --triggerClientEvent("givePlayerCreditTimer",player_) -- даёт таймер игроку, который будет сохраняться при выходе и выдаваться при входе игрока setElementData(player_,"isCredit",true) setElementData(player_,"CreditAmount",amount) -- не забыть проверку на макс. количество денег, которые можно взять в долг. if not timeleft_timer then --tim = creditDays*86400000 tim = creditDays*1000 else tim = timeleft_timer end outputChatBox(11) timers[player_] = setTimer( function() outputChatBox(22) if type_ == "house" then --exports.res-houses -- забрать дом elseif type_ == "vehicle" then outputChatBox(33) --exports.salo -- забрать авто dbExec(db2, "DELETE FROM VehicleList WHERE Account = ? AND isCreditCar = ?", getAccountName(getPlayerAccount(player_)), true) for i, v in ipairs(getElementsByType("vehicle")) do if getElementData(v,"ownercar") == getAccountName(getPlayerAccount(player_)) then destroyElement(v) outputChatBox(44) end end exports["res-houses"]:calculateCarLimit(player_) setElementData(player_,"carCount",getElementData(player_,"carCount")-1) outputChatBox("Вы не успели вовремя оплатить кредит, поэтому государство отняло у вас авто.",player_) elseif type_ == "money" then -- coming soon end end,tim,1) player_ = nil type_ = nil amount = nil timeleft_timer = nil tim = nil end Each time i login(even from new account) i see in chat 11 and then 22 after 3-5 seconds. I want to sell a vehicle temporary. So I create a timer ( 7 seconds) and when it's over, script removes database entry with this car and with timer info in another database. I feel discouraged right now and i don't know what to do\
-
Thanks! That's even better than patterns)
-
Hello everyone! How can i allow player to input only numbers? I mean he/she can write only numbers in editbox, but when a player tries to write letter or *&$% things\ nothing will happen. How can i compare it with pattern? or something like that?
-
Hello everyone! I have a question. function cammode () local x,y,z = getElementPosition(localPlayer) x = x + 1 local xx,yy,zz = getPositionInFrontOfElement(localPlayer) xx = xx + 1 setCameraMatrix (x,y,z+0.5,xx,yy,zz+0.5) end This part of code will rotate camera well with vehicle until i change x and xx variables. I can only change the height. When i change x, xx variables camera starts moving around. I want to get x and y variables related to vehicle rotation and feel free to change them as i want. Can someone help or give me an example to make better calculations?
-
yeah, i guess the problem was here)
-
Thank you! It works! I can't understand why it didn't work before. Maybe i wrote a formula wrong
-
vertical blinking line still visible\\ even with alpha = 0
-
Maybe. But I need a transparent editbox to see only words without vertical blinking line and editbox background
-
Ok, but i replaced it with detail command and keep getting the same resul :\
-
my part of code: addCommandHandler("check",function(cmd, stre, stre2, value) if (stre and stre2 and value) then stre = stre:lower() print("stre = "..stre) stre2 = stre2:upper() print("stre2 = "..stre2) end end) it doesn't work here
-
Hello everyone! I have a little problem: mystring = "somE teXt" mystring = mystring:lower() outputChatBox(mystring) i get in chat somE teXt so string.lower function doesn't work for me. Help me please
-
i forgot that i used setElementParent instead. I added attachElements and it works now. Thank you! but now it is not attaches properly\ soo how can i use only setElementParent to detect objects? getElementParent can return only a vehicle - not a vehicle attached part
-
Hello everyone! My code doesn't work for unknown reason: addCommandHandler("ivi",function() det = getAttachedElements(getPedOccupiedVehicle(localPlayer)) for u , num in ipairs(det) do outputDebugString(tostring(num)) end end) Any ideas? Maybe i'm doing something wrong\\\
-
Hello everyone! How can i work with vehicle parts elements? For example i want to focus player's camera on certain part. Also i want to attach other objects to vehicle part without using custom model's offsets. Any ideas?
-
Hello everyone! I started to learn render targets in lua. So the question is: Can i use dxDraw functions on vehicles? I think i should apply a shaders to use it. Some people use texreplace.fx for drawing. As i know, this people create a render target, draw some stuff on it, get pixel colours and apply a texture on the vehicle with shaders. Is there any other ways? Maybe i can draw text/images directly on vehicle texture (i added special texture to car called "bodytex" for this action) somehow\\\ Applying shaders each time reflects on perfomance a lot
-
- render targets
- shaders
-
(and 2 more)
Tagged with:
-
adding * creates an error. dbPoll(dbQuery(db, "SELECT COUNT(Account) FROM AllAccTable WHERE acc = ?", toJSON(getAccountName( acc ))), -1) My code returns number 1 even when the database is empty/ Help!
-
you wrote (at the end of the script): end) end) you should write: end) your function closed if (source == windowclose) then destroyElement(window) addEvent("showDrugs", true) end addEventHandler("onClientGUIClick",windowclose, function() -- your function end )
-
check your functions and exports again. I've recently used exports too: resource: house_sys file: server.lua function calculateLimit (player) -- actions end resource: house_sys file: meta.xml <export function="calculateLimit" type="server"/> resource: vehshop file: serv.lua exports["house_sys"]:calculateLimit(source) Check exported function for mistakes. Also i exported server-side function with type="server" and used only in server-side scripts server-side scripts have to look in both resources (in meta.xml) like this: <script src="your_name.lua" type="server" />
-
function createVehToSpawn(vehiclemodelid, posx,posy,posz, rotx,roty,rotz, freezeonspawn) local veh = createVehicle(vehiclemodelid, posx,posy,posz, rotx,roty,rotz) setVehicleColor(veh, 253, 140, 29, 253, 140, 29, 253, 140, 29 ,253, 140, 29) setElementData(veh, "tablerow", {vehiclemodelid, posx,posy,posz, rotx,roty,rotz, freezeonspawn}) setElementData(veh,"SpecialVeh",true) -- we added data to determine that this vehicle is from current script addEventHandler("onVehicleExplode", veh, respawnVehicle) if freezeonspawn then setElementFrozen(veh, true) addEventHandler("onVehicleEnter", veh, function() setElementFrozen(source, false) end) addEventHandler("onVehicleExit", veh, function() setElementFrozen(source, true) end) end end addCommandHandler("ExpVehicles", function() for i,v in pairs(getElementsByType("vehicle")) do if getElementData(veh,"SpecialVeh") then -- check the data --destroyElement(v) -- if you want do destroy all cars blowVehicle(v) -- if you want to blow up all cars end end end ) Also you can add ACL check for this command
-
Hello everyone! Maybe i'm in wrong section but still it related to scripting i guess Could you check me please? dbPoll(dbQuery(db, "SELECT COUNT(Account) FROM AllAccTable WHERE acc = ?", toJSON(getAccountName( acc ))), -1) I want to count rows in table AllAccTable in Account column where acc matches with current player's account name (for example i want to get all rows with certain player from 9999 rows)
-
ok, i understand it now. Thank you!