-
Posts
142 -
Joined
-
Last visited
-
Days Won
6
Everything posted by FlorinSzasz
-
Well you should play with x ,y , z rotation. You can try rotate the camera to match your wish.
-
Motorcycles and bicycles setElementPosition bug
FlorinSzasz replied to relvarten's topic in Scripting
If i am not wrong u can use fade camera so the teleport wont look as bad as it is. -
I dont think u can do that in mta or gta sa from the way the game was made, here is a topic maybe u find it usefull:
-
Well something like this could work i never did one such system but u need something like math.random() or some kind of function to get some random numbers function bet_some_money(thePlayer,CommandName,amount) if source == thePlayer then -- check for player local playerMoney = getPlayerMoney(thePlayer) -- get how much money has the player who calls the command if amount ~= nil and type(amount) == "number" then -- check if amount is not nil and also if it is a number if amount <= playerMoney then -- chek if amount is not more than all the money he has at him now takePlayerMoney(thePlayer,amount) -- take the money local number = math.random(0,1) -- a random number also u can use a table with numbers or % if number == 0 then outputChatBox("[BET] You lose this time, maybe u have more luck next time!",thePlayer,255,104,104) elseif number == 1 then outputChatBox("[BET] You won gg man :D",thePlayer,104,255,104) givePlayerMoney(thePlayer,2*amount) -- give player 2 x amount end end end end end also this code is not tested!!!
-
Eu o sa incerc sa fac un fel de server cu freeroam/race/rpg/minigames/stunt poate un sistem cu magazine ce au stock propriu și unul cu organizați îți cumperi teren clădiri etc. nush cat o să prindă dar să fie acol o sa pun acol tot ce am văzut mai cool pe serverele de samp pe care am jucat cândva și ideile pe care le am. Nu sunt scripter pro cel mai mult intermediar însă am cunostințe cât să pun în scris ceea ce îmi propun. Lucrez de 2-3 ani la el dar pe perioade, în prezent am job și sunt și la faculta cumva il termin :)) poate până la vară
-
local test_locations = {} function test_someting() test_locations[1]=createMarker(2199.92871,-1671.48145,14.41751 - 1,"checkpoint",4.0,53,151,255,45) test_locations[2]=createMarker(2181.92944,-1713.81812,12.74913 ,"checkpoint",4.0,53,151,255,45) test_locations[3]=createMarker(2209.10229,-1658.24084,14.79899 - 1,"checkpoint",4.0,53,151,255,45) test_locations[4]=createMarker(2219.04077,-1687.14417,13.334671,"checkpoint",4.0,53,151,255,45) end addCommandHandler("test2",test_someting,false,false) local function test(hitPlayer,matchingDimension) for k,v in ipairs(test_locations) do if source == test_locations[k] then outputChatBox(""..k.."") destroyElement(test_locations[k]) end end end addEventHandler("onClientMarkerHit",getRootElement(),test) Solved, i got back to scripting after months! So in this way from all the markers i destroy only the one i hit.
-
Well this works too thx . But i wonder how the game gets that markers[source] is markers[mark] i hope u can give me an ideea or someone.
-
local test_locations = {} function test_someting() test_locations[1]=createMarker(-106.93572235107,-1150.2275390625,1.0437397956848-1,"cylinder",4.0,53,151,255,45) test_locations[2]=createMarker(-129.19007873535,-1202.5013427734,2.1060457229614,"cylinder",4.0,53,151,255,45) test_locations[3]=createMarker(-142.54978942871,-1272.1796875,2.1073033809662,"cylinder",4.0,53,151,255,45) end addCommandHandler("test2",test_someting,false,false) local function test(hitPlayer,matchingDimension) for i = 1,3 do if source == test_locations[i] then outputChatBox(""..i.."") destroyElement(test_locations[i]) end end end addEventHandler("onClientMarkerHit",getRootElement(),test) Hi guys, i try to spawn for a job more markers at once and when i hit one i want to check which one i hit. I tried to do this first time 1. i made a table and wrote the markers coords 2. i wrote a function with a ipairs loop in it to make the markers 3. i wrote the function for onClientMarkerHit event but the thing is only the first marker reacts to it and 2nd or 3rd or any other marker from table wont but they are created/spawned Is there another way to check which marker i hit from all created from a table than the method from above.
-
i also looked up on wiki at that function didnt know how to modify it for my need. Thank you !! IT WORKS :D. I will use the string to make a 3D text with gang CapturePoints in ballas and grove gang base. In the past i did it but in a simple way and now i got back to scripting and i lost my last backup with scripts so i have to remade some of them and to fix this thing again . Thx Again!!!
-
I try to get the value from the table or if i can remove the curly-brackets i am close but not there yet :)) cappoints = function () local Query = dbQuery(db,"SELECT SUM(capturepoints) AS CapturePoints FROM grove") local Query2 = dbQuery(db,"SELECT SUM(capturepoints) AS CapturePoints FROM ballas") local rezultat = dbPoll(Query,-1) local rezultat2 = dbPoll(Query2,-1) ------ for _, name in ipairs(rezultat) do local a = inspect(name) local string = string.gsub(a,"{","") local string2 = string.gsub(a,"}","") iprint(a) outputDebugString(""..string2.."") end end addEventHandler("onResourceStart",root,cappoints) i changed the code to debug faster. now i get "{\n CapturePoints = 1100\n}" from iprint and "{ CapturePoints = 1100 " from debug string output one more bracket left :))
-
Hi guys! I try to output a string from json but what i get is [ [ { "CapturePoints": 1100 } ] ] and [ [ { "CapturePoints": 600 } ] ] all i want is to remove the brackets if i use fromJSON i get something like this table: 070593C8 and table: 070593F0. Here is the code cappoints = function () local Query = dbQuery(db,"SELECT SUM(capturepoints) AS CapturePoints FROM grove") local Query2 = dbQuery(db,"SELECT SUM(capturepoints) AS CapturePoints FROM ballas") local rezultat = dbPoll(Query,-1) local rezultat2 = dbPoll(Query2,-1) local abc = toJSON(rezultat) local abc2 = toJSON(rezultat2) setElementData(source,"suma",abc) setElementData(source,"suma2",abc2) outputChatBox(""..string.gsub(abc,"[[{}]]","").."",source) outputChatBox(""..string.gsub(abc2,"[[{}]]","").."",source) end addEventHandler("onPlayerJoin",root,cappoints) Thank you in advance for anyone who can help me!
-
Thank you! It works now, also i had to remove the "LIMIT 1" otherwise it will give me a syntax error, strange usually "LIMIT" is usefull and works , even then it updates corectly. Thank you again ?.
-
Hi guys! I try to make a business system from scratch. Everything is fine until i got to the point of making the withdraw part for example my payout is 5500$ and my bank is 11.000$ i withdraw 11k now and my db updates and the bank is 0 but when the payout time ends and my db gets updated my bank is not 5500$ is 16.500$. Also no errors in debugscript 3 Server Side local seconds = 1000 local minute = 60 * seconds local hour = 60* minute local conexiune = dbConnect( "sqlite", "afacere.db" ) if conexiune then outputDebugString( "Connection with AFACERE database was successfully established." ) else outputDebugString( "Connection with database couldn't be established." ) end afacerebase = function() dbExec(conexiune,"CREATE TABLE IF NOT EXISTS afacere (NR INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,x INTEGER,y INTEGER,z INTEGER,cost INT,owner TEXT,payout INT, time INT,balance INT)") end addEventHandler("onResourceStart",getRootElement(),afacerebase) -- s -- m -- h createAfacere = function(player,commandName,cost,payout,type,time) local owner = "DE VANZARE" local x,y,z = getElementPosition(player) local balance = 0 if time == nil then return end if tostring(type) == "h" then dbExec(conexiune,"INSERT INTO afacere (x,y,z,cost,owner,payout,time,balance) VALUES (?,?,?,?,?,?,?,?)",x,y,z,cost,owner,payout,tonumber(hour*time),balance) outputDebugString("1") elseif tostring(type) == "s" then dbExec(conexiune,"INSERT INTO afacere (x,y,z,cost,owner,payout,time,balance) VALUES (?,?,?,?,?,?,?,?)",x,y,z,cost,owner,payout,tonumber(seconds * time),balance) outputDebugString("2") elseif tostring(type) == "m" then dbExec(conexiune,"INSERT INTO afacere (x,y,z,cost,owner,payout,time,balance) VALUES (?,?,?,?,?,?,?,?)",x,y,z,cost,owner,payout,tonumber(minute * time),balance) outputDebugString("3") end createPickup(x,y,z,3,1274,1) createBlip(x,y,z,52,2.5,150,150,150,255,0,200) end addCommandHandler("afacere",createAfacere,false,false) deleteAfacere = function(player,commandName,cod) if cod == nil then return outputChatBox("[AFACERE] Nu ai introdus un ID syntax error <cod>",source) end local query = dbQuery(conexiune,"SELECT NR FROM afacere WHERE NR=? LIMIT 1",tonumber(cod)) local result = dbPoll(query,-1) if result then for k,v in ipairs(result) do if tonumber(v.NR) ~= tonumber(cod) then outputChatBox("EROR",source,255,0,0) else dbExec(conexiune,"DELETE FROM afacere WHERE NR=?",tonumber(cod)) outputChatBox("Succes",source) end end else outputChatBox("NOT FOUND 404",source,255,10,10) end end addCommandHandler("killafacere",deleteAfacere,false,false) startloading = function() local query = dbQuery(conexiune,"SELECT * FROM afacere") local result = dbPoll(query,-1) if result then for k,v in ipairs(result) do afacereglobala = createPickup(v.x,v.y,v.z,3,1274,1) createBlip(v.x,v.y,v.z,52,2.5,150,150,150,255,0,200) setElementData(afacereglobala,"afacere_ID",v.NR) setElementData(afacereglobala,"x",v.x) setElementData(afacereglobala,"y",v.y) setElementData(afacereglobala,"z",v.z) setElementData(afacereglobala,"afacere_cost",v.cost) setElementData(afacereglobala,"afacere_owner",tostring(v.owner)) setElementData(afacereglobala,"afacere_payout",v.payout) setElementData(afacereglobala,"afacere_time",v.time) setElementData(afacereglobala,"afacere_balance",v.balance) local TIMP = setTimer(start_money,v.time,1,afacereglobala); end end end addEventHandler("onResourceStart",getRootElement(),startloading) addEventHandler("onResourceStart", resourceRoot, function() for k, v in ipairs(getElementsByType("player")) do bindKey(v, "1", "down", "afacere") end end) addEventHandler("onPlayerJoin", root, function() bindKey(source, "1", "down", "afacere") end) function open_menu(p) if getElementData(p,"open_w") == false then local x,y,z = getElementPosition(p) local query = dbQuery(conexiune,"SELECT * FROM afacere") local result = dbPoll(query,-1) if result then for k,v in ipairs(result) do if getDistanceBetweenPoints3D(x,y,z,v.x,v.y,v.z) <= 2.5 then triggerClientEvent(p,"afacere_menu",p,v.NR,v.owner,v.payout,v.cost,v.balance,v.time,v.x,v.y,v.z) end end end else end end addCommandHandler("afacere", open_menu) addEvent("buy_afacere",true) buy_now = function(ID,payout,balance,timer,nume) local nume = nume dbExec(conexiune,"UPDATE afacere SET owner=? WHERE NR=?",tostring(nume),tonumber(ID)) setTimer(start_money,timer,1,afacereglobala) end addEventHandler("buy_afacere",getRootElement(),buy_now) start_money = function(afacereglobala) local ID = getElementData(afacereglobala,"afacere_ID") local x= getElementData(afacereglobala,"x") local y= getElementData(afacereglobala,"y") local z= getElementData(afacereglobala,"z") local cost getElementData(afacereglobala,"afacere_cost") local owner = getElementData(afacereglobala,"afacere_owner") local payout = getElementData(afacereglobala,"afacere_payout") local time = getElementData(afacereglobala,"afacere_time") local lock = getElementData(afacereglobala,"afacere_balance_lock") local balance = getElementData(afacereglobala,"afacere_balance") if owner ~= "DE VANZARE" then balance = balance + payout dbExec(conexiune,"UPDATE afacere SET balance=? WHERE NR=?",balance,ID) end local TIMP = setTimer(start_money,time,1,afacereglobala) setElementData(afacereglobala,"afacere_balance",balance) end addEvent("get_money",true) get_money = function(name,ids,acc_balance) local bank = tonumber(getElementData(afacereglobala,"afacere_balance")) if name ~= "DE VANZARE" then givePlayerMoney(source,acc_balance) setElementData(afacereglobala,"afacere_balance",0) dbExec(conexiune,"UPDATE afacere SET balance=? where NR=?",bank - bank,ids) end end addEventHandler("get_money",getRootElement(),get_money) Client Side local client = getLocalPlayer() local info = {} addEvent("afacere_menu",true) open_afacere_menu = function(ID,owner,payout,cost,balance,timer,x_aff,y_aff,z_aff) info[1] = ID info[2] = owner info[3] = payout info[4] = cost info[5] = balance info[6] = timer setElementData(getLocalPlayer(),"open_w",true) local screenW, screenH = guiGetScreenSize() afacerewindow = guiCreateWindow((screenW - 500) / 2, (screenH - 300) / 2, 500, 300, "AFACERE", false) guiWindowSetMovable(afacerewindow, false) guiWindowSetSizable(afacerewindow, false) BuyAfacere = guiCreateButton(15, 247, 119, 34, "BUY", false, afacerewindow) guiSetProperty(BuyAfacere, "NormalTextColour", "FFAAAAAA") SELL_afacere = guiCreateButton(154, 247, 119, 34, "SELL", false, afacerewindow) guiSetProperty(SELL_afacere, "NormalTextColour", "FFAAAAAA") GET_MONEY = guiCreateButton(293, 247, 119, 34, "GET MONEY", false, afacerewindow) guiSetProperty(GET_MONEY, "NormalTextColour", "FFAAAAAA") cancel_afacere = guiCreateButton(423, 247, 67, 34, "X", false, afacerewindow) guiSetProperty(cancel_afacere, "NormalTextColour", "FFAAAAAA") Info_afacere = guiCreateMemo(154, 15, 340, 230, "AFACERE ID : "..ID.."\nSTATUS: "..owner.."\nPAY_OUT: "..payout.."\nCOST: "..cost.."\nBALANCE: "..tostring(balance).."\nTimer for payout in minutes: "..(timer/60000).."\nX: "..x_aff.."\nY: "..y_aff.."\nZ: "..z_aff.."\n------------------------------------------------------------------------------", false,afacerewindow) guiCreateStaticImage(15,15, 128, 128,"$.png",false,afacerewindow) guiCreateStaticImage(15,120,128, 128,"money2.png",false,afacerewindow) guiMemoSetReadOnly(Info_afacere, true) showCursor(true) addEventHandler ( "onClientGUIClick",cancel_afacere, close_afacere_menu,false) addEventHandler ( "onClientGUIClick",BuyAfacere, buy_afacere_menu,false) addEventHandler("onClientGUIClick",GET_MONEY,get_money_menu,false) end addEventHandler("afacere_menu",getRootElement(),open_afacere_menu) close_afacere_menu = function(button,state) if (button == "left") and (state == "up") then showCursor (false) guiSetVisible(afacerewindow,false) setElementData(getLocalPlayer(),"open_w",false) end end buy_afacere_menu = function(button,state) if (button == "left") and (state == "up") then if info[2] == "DE VANZARE" and getPlayerMoney(getLocalPlayer()) >= info[4] then local nume = getPlayerName(getLocalPlayer()) showCursor (false) guiSetVisible(afacerewindow,false) outputChatBox("[AFACERE] Ai cumparat o afacere :D",0,50,255) setElementData(getLocalPlayer(),"open_w",false) takePlayerMoney(info[4]) triggerServerEvent("buy_afacere",getLocalPlayer(),info[1],info[3],info[5],info[6],nume) elseif info[2] ~= "DE VANZARE" then outputChatBox("[AFACERE] Aceasta afacere este detinuta deja de catre cineva",150,0,0) elseif info[2] == "DE VANZARE" and getPlayerMoney(getLocalPlayer()) < info[4] then outputChatBox("[AFACERE] Nu ai destui bani pentru a cumpara aceasta afacere",150,0,0) end end end get_money_menu = function(button,state) local name = getPlayerName(client) if (button == "left") and (state == "up") then if info[2] == "DE VANZARE" then outputChatBox("[AFACERE] Aceasta afacere nu este detinuta de tine ") elseif name == info[2] and info[5] >0 and info[5] >=16500 then guiSetVisible(afacerewindow,false) setElementData(getLocalPlayer(),"open_w",false) showCursor (false) triggerServerEvent("get_money",client,info[2],info[1],info[5]) elseif name ~= info[2] then outputChatBox("[AFACERE] Aceasta afacere nu este detinuta de tine ") end end end Here is the full code.