-
Posts
605 -
Joined
-
Last visited
-
Days Won
1
Everything posted by JeViCo
-
Possible problems: 1) Script: Check variable values before updating/saving into database. They might have nil values 2) Database: 1) Wrong column types may cause problems 2) Wrong column length may cause problems
-
You can't manage meta.xml file client-side (security reasons) however you can do whatever you want server-side get everything you need server-side, trigger client event to transfer data and use it
-
On my opinion vehicle creation takes a little amount of time to manage it's data. Try to use setTimer setTimer(setVehicleComponentVisible, 100, 1, vehicle, component, visible)
-
I guess it's because of the second argument of dbPoll function: local results = dbPoll(qh, 0) Try to use -1 instead of 0 or use little amount of time like 500-1000 ms local results = dbPoll(qh, -1) -- wait until a result is ready
-
addCommandHandler("addVip", function(pl, cmd, ...) local nick = table.concat({...}, " ") local player = getPlayerFromPartialName(nick) if not player then return end local acc = getPlayerAccount(player) local accName = getAccountName(acc) aclGroupAddObject(aclGetGroup("Vip"), "user."..accName) aclReload() -- apply changes end, true) Mistake was there: getAccountName(player) I used player element instead of account By the way, don't forget to add command.addVip permission to use command
-
If you want to make private marker - create it client-side! You may also create it server-side however you should use setElementVisibleTo and check for player you need
-
Sorry for my bad explanation ? Try this code: local mouseClick -- additional variable function tabsPage() if getKeyState("mouse1") then if isCursorWithin(posX, referee.y, sizeX, sizeY) and not mouseClick then outputChatBox("page 1") addEventHandler("onClientRender", root, referee.dxPage1) addEventHandler("onClientClick", root, onClickPage1) -- playersPanel = false removeEventHandler("onClientRender", root, referee.dxPage2) -- mouseClick = true -- 'button click' - click detected. No more code executing elseif isCursorWithin(posX + textmoveX, referee.y, sizeX, sizeY) and not mouseClick then outputChatBox("page 2") removeEventHandler("onClientRender", root, referee.dxPage1) removeEventHandler("onClientClick", root, onClickPage1) -- addEventHandler("onClientRender", root, referee.dxPage2) -- mouseClick = true -- 'button click' - click detected. No more code executing else mouseClick = false -- nothing happend - returning to normal state end end end
-
if getKeyState("mouse1") then if isCursorWithin(posX, referee.y, sizeX, sizeY) then this part of code will execute each frame (onClientRender) while you're holding left mouse button (getKeyState("mouse1")) and cursor is there (posX, referee.y, sizeX, sizeY) You need to add an additional variable to use click event once
-
Problem hides here: function changeWeather(player, command, state, weatherID, weatherName) your function redefines value of weatherName variable in current scope. You probably want this (inside your function): local selected = weatherName[tonumber(weatherID)] -- get text from table also remove last function argument to make everything work function changeWeather(player, command, state, weatherID)
-
I made script a long time ago. I've tried to apply shader on weapon in different ways but got nothing. Weapons you holding are not actually objects (for some reason) and that's pretty annoying sometimes. Anyway i solved that problem: 1. I replace weapon with custom dff and txd with transparent texture. (You can see it in video below at the beginning. Replacing provides correct muzzle offset for custom weapon); 2. I replace 1 random object (not weapon) with my weapon's dff and txd normally; 3. When ped gets ak47 (weapon) i create shader with texture replacement, apply it on my object (not ped) and use render target as texture; 4. When i switch to ak47 i attach weapon to player's hand (using bone_attach resource) and remove it if i switch to another weapon; 5. I use render targets so i can easily redraw the texture and that's it.
-
function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end addCommandHandler("addVip", function(pl, cmd, ...) local nick = table.concat({...}, " ") local player = getPlayerFromPartialName(nick) if not player then return end local accName = getAccountName(player) aclGroupAddObject(aclGetGroup("Vip"), "user."..accName) end) Try this code
-
you mean this? if not isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( player ) ), aclGetGroup ( "Policja" ) ) then return end
-
Example code: local scx, scy = guiGetScreenSize() local text = "hello world" showCursor(true) addEventHandler("onClientRender", root, function() if isCursorShowing() then -- can be removed local cx, cy = getCursorPosition() local boxW = dxGetTextWidth(text) + 2*20 -- add left and right paddings local boxH = dxGetFontHeight() + 2*10 -- add top and bottom paddings dxDrawRectangle(cx*scx, cy*scy, boxW, boxH) dxDrawText(text, cx*scx, cy*scy, boxW+cx*scx, boxH+cy*scy, tocolor(0, 0, 0, 255), 1, "default", "center", "center") end end) Result: Also don't forget about scale, font and color-coded properties which affect on dxGetTextWidth, dxGetFontHeight and drawing functions
-
You want to draw rectangle next to cursor, am i right? getCursorPosition returns values from 0 to 1 so you should multiply values to get absolute coordinates like this: local scx, scy = guiGetScreenSize() local cx, cy = getCursorPosition() addEventHandler("onClientRender", root, function() dxDrawRectangle(cx*scx, cy*scy, 300, 100) end)
-
@xxMANxx, you probably need this function Math.isPointInPolygon. You should iterate through each point of one rectangle and check if one of them is inside the other one
-
[C#] luac.mtasa.com api post request problem
JeViCo replied to JeViCo's topic in Site/Forum/Discord/Mantis/Wiki related
Solved, my bad. So what was wrong? 1. I was trying to send code as plain text. I had to send a file, not a text. 2. I thought content type had to be "application/x-www-form-urlencoded". Nope - "multipart/form-data" (found in luac.multitheftauto.com's web page source code) 3. UTF-BOM and UTF without BOM didn't work for me so i used Encoding.Default everywhere (fixed StreamWriter too) -
Possible solution: convert otf to ttf font
-
if ( player_faggio1~=localPlayer) then -- player is not in faggio teleport vehicle to player setElementPosition(faggio1, x, y, z)
-
@Scyrix On my opinion the problem is right here: local results = dbPoll(queryHandle, 0) change result timeout from 0 to -1: local results = dbPoll(queryHandle, -1) Wiki: Use 0 for an instant response (which may return nil)
-
if account = false (boolean) then the problem is somewhere around here getAccount(username, password) Also i don't see any "submitLogin" event triggering in your code. Possible problems: - "submitLogin" event arguments are missing - "submitLogin" event arguments are incorrect and getAccount function says "i don't know this person"
-
[C#] luac.mtasa.com api post request problem
JeViCo replied to JeViCo's topic in Site/Forum/Discord/Mantis/Wiki related
It seems that api does not support programming-based remote access. PHP script has same result - "ERROR Could not compile file". Code: <?php $data = array( 'compile' => '1', 'debug' => '0', 'obfuscate' => '3', 'luasource' => 'print("Hello World!")' ); $query = http_build_query ($data); $contextData = array ( 'method' => 'POST', 'header' => "Content-type: application/x-www-form-urlencoded\r\n". "Connection: close\r\n". "Content-Length: ".strlen($query)."\r\n", 'content'=> $query ); $context = stream_context_create (array ( 'http' => $contextData )); $result = file_get_contents ('https://luac.multitheftauto.com/index.php', false, $context); echo $result; -
[C#] luac.mtasa.com api post request problem
JeViCo replied to JeViCo's topic in Site/Forum/Discord/Mantis/Wiki related
Hello, thanks for reply! I've tried to implement that method and got the same result. Updated code: using System.Net.Http; private string PostRequest(string text) { var values = new Dictionary<string, string> { { "compile", "1" }, { "debug", "0" }, { "obfuscate", "3" }, { "luasource", "local a = 10" } // example code }; using (var client = new HttpClient()) { var content = new FormUrlEncodedContent(values); var response = client.PostAsync("https://luac.multitheftauto.com/index.php", content).Result; //var response = client.GetAsync("http://google.com").Result; if (response.IsSuccessStatusCode) { var responseContent = response.Content; // by calling .Result you are synchronously reading the result string resp = responseContent.ReadAsStringAsync().Result; Console.WriteLine(resp); // ERROR Could not compile file return resp; } else { return "Error connecting website"; } } } I had some problems with async methods in sync thread however i fixed it somehow -
Awesome idea, however it sounds impossible for a single person. Since collisions are client-side, bullets, object and ped ragdolls will be asynced. It may cause additional problems in future so you have to deal with server as well. Anyway i guess it's time to go onto the next level for good old SA so good luck ?
-
I have a code: private static string PostRequest(string text) { WebRequest request = WebRequest.Create("https://luac.multitheftauto.com/index.php"); request.Method = "POST"; string data = "compile=1&debug=0&obfuscate=3&luasource=" + text; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = byteArray.Length; using (Stream dataStream = request.GetRequestStream()) { dataStream.Write(byteArray, 0, byteArray.Length); } WebResponse response = request.GetResponse(); string resp; using (Stream stream = response.GetResponseStream()) { using (StreamReader reader = new StreamReader(stream)) { resp = reader.ReadToEnd(); } } response.Close(); return resp; } which should return compiled and obfuscates version of text but there is a problem - it always returns "ERROR Could not compile file" even if i use "local a = 10" string as a text. I guess that problem hides in ContentType variable and urlencoded maybe ruins Lua code however i don't know how to fix it right now.