
DarkStalker30
Members-
Posts
36 -
Joined
-
Last visited
-
Days Won
1
Everything posted by DarkStalker30
-
I found another way. On start interface resource add and instant remove armor to localPlayer, it's turning on armor bar, then taking health bar coords, armorY + (healthY - armorY) / 2 = breathY. And it's working perfect. UPDATE: for correct working of this method you need to let armor bar to be drawn for 1 frame at least. I used a timer, which checking armorX and armorY, until they became not 0, 0.
-
That's something that I want to do. And if breath bar has its coords, then all ok. But if not, then stamina bar going to left top corner. I just can't upload images. If character will be in water while player has black screen by fadeCamera() and HUD off, will it trigger breath bar?
-
Hi guys. In 1.6 was added some new functions for HUD. I liked the idea to use it to draw my stamina bar in place, where is breath bar by default. But then I got a problem - until the player gets into the water, breath bar x, y = 0, 0. Is there a way to force draw that bar without going into water?
-
Okay then, thanks a lot! I will try it later
-
Well, looks like it can be changed with timer too smooth transition. But it will take time to figure this out. If really, I don't understand how can I freeze lighting. Timer with setSkyGradient()? SetWorldProperty() looks interesting, but many works to do as well. I guess, for now I leave it, because my server on early stage of development. So if I can to do it simple and hacky way - I will do it, if not - then leave it.
-
Hi guys, didn't write some time, but now want to return. I have an idea to use different weather on the map, because as you know in single SA different regions have different weather. I find a way to do it - when player changing region (prototype for now, in future will do collision cubes) start setWeatherBlended() and then accelerate game time with setMinuteDuration(), after it return time to the server. But it has problem, because with fast time you will get fast day and night. If in some border time like between 20:00 and 22:00 you can even didn't notice it, then at another time it's too obvious. Is there a way to freeze lighting to create illusion of not changing time?
-
Well, I tried to use it, but GPT very stupid in code, really. And stupid by itself. You probably don't want to use it for real code, only for ideas or simple monkey job. And it's loving to invent new functions in standard MTA, so you need to check it on wiki or in IDE with code highlighting. I guess it's because on MTA not so many free code in network. Maybe new versions will can do it better, but not now.
-
Is there an easier way to be doing dxTextDraw?
DarkStalker30 replied to XeroXipher's topic in Scripting
You can save your coordinates to the variables, and the use them to build text. Like: local rectangleStartX = x*1200 local rectangleWidth = x*1400 dxDrawText(rectangleStartX + rectangleWidth + 10, etc...) But i'm not sure right now about your coordinates, because "width" for dxDrawRectangle - it's not the endpoint, if wiki is right And then code will be more easy, because for width you can use just "200". As for take coordinates from rectangle - well, looks like it can't be done in MTA. P.S. I'm not good in UI scripting, just trying to help with simple logic. -
Solution: local shader = dxCreateShader("texture.fx", 0, 0, false, "ped") Thanks @IIYAMA for help!
-
"*" applies shader to all textures. And I already tried this, found name of texture in skin page and wrote it. Didn't work.
-
Hello everyone, I'm trying to work with shaders. For now it just simple texture replace, but I can't apply it on local player. Other textures change OK. texture.fx code (simplest): texture myTexture; technique ClothesShader { pass P0 { Texture[0] = myTexture; } } Client code: local shader = dxCreateShader("texture.fx") local texturesTable = { [1] = dxCreateTexture("1.png"), [2] = dxCreateTexture("2.png"), [3] = dxCreateTexture("3.png") } addCommandHandler("testclothe", function(_, variant) variant = tonumber(variant) if variant > 0 and variant < 4 then dxSetShaderValue(shader, "myTexture", texturesTable[variant]) engineApplyShaderToWorldTexture(shader, "*", localPlayer) end end) No any errors, all files added in meta.xml. As I said before, this code can apply shader to all textures, if delete "localPlayer" from arguments, but it can't apply on player, and I can't understand, why. I readed on wiki "engineApplyShaderToWorldTexture", and saw the recommend of using argument "elementTypes" as "ped" or "all", but if it's the problem, then I don't know, what to put in other arguments (and I think that default value of this argument include "all"). If need, can add screenshots, but it only duplicates that text message.
-
Yes, I've already did strings like that, and it works correctly (not when I'm trying to do multiple statement). I can't remember, where I found it, but it was on MTAWiki 99%, or some resource which was referenced by wiki. Example: local insertString = "INSERT INTO `houses`\ (`house_owner_id`, `house_enter_x`, \ `house_enter_y`, `house_enter_z`, `house_enter_rotation`, \ `house_exit_x`, `house_exit_y`, `house_exit_z`, \ `house_exit_world`, `house_exit_dimension`, `house_exit_rotation`, \ `house_interior_type`, `house_base_price`, `house_current_price`) \ VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?);" Works 100% good, no errors or data corruption in tables. I didn't knew about this, I'll check. But if the problem in that flag, this is weird, that error by MySQL. Yes, this is the solution. Thank you very much, I would never have guessed where is the problem.
-
Hello everyone, I have a problem with database. I'm trying to add outfit into database and update player's info, but every time I'm getting this trouble: String to use: local insertString = "INSERT INTO `inventories`(`inventory_type`, \ `inventory_big_sells`, `inventory_mid_sells`, `inventory_small_sells`, \ `inventory_max_weight`, `inventory_owner_id`) VALUES \ ('outfit','0','0',?,'-1',?);\ UPDATE `chars_invs` SET `char_inv_outfit`=? WHERE `char_inv_id`=?;" It looks like correct SQL code. In phpMyAdmin SQL field I tried too, and it didn't create any errors, but in MTA it's not work. I can guess that because nearby "UPDATE" appears ', but I don't know how to fix that. Any ideas?
-
Some vehicles "engineRequestModel" features
DarkStalker30 replied to DarkStalker30's topic in Скриптинг
Да. Well, I assumed that. Okay, if with sirens I can creating something new, did you find any another ways to script work for that models? Or it can work only on standard models (I read bugreport and find all I now right now about non-working models, but I have no idea how it can be fixed by MTA scripts)? Thanks for framework, but I'm trying to do as much as possible by myself, because it's interesting for me in that way. And thanks for help! -
Some vehicles "engineRequestModel" features
DarkStalker30 replied to DarkStalker30's topic in Скриптинг
Во втором куске я просто пропустил часть кода, так как там ещё срабатывает пара штук, и модель, если она оригинальная, переопределяется там же. Как я уже писал, на стандартных работает хорошо, на заменённых - нет, но оно добавляется, так как звук есть. В первом не совсем понял смысла дописывать ещё один setElementData, так как это происходит при спавне машины, и он уже есть. newModelName - это как раз оно, я просто тут тоже не весь код привёл, чтобы он не таким большим был, но забыл, что некоторые детали могут быть важны Короче, все эти исправления, которые ты предложил, у меня уже есть, и оно всё равно не работает)) -
Some vehicles "engineRequestModel" features
DarkStalker30 replied to DarkStalker30's topic in Скриптинг
local modelTable = newModelsTable[newModelName] if modelTable then if modelTable.currentID == nil then modelTable.currentID = engineRequestModel("vehicle", modelTable.parentID) local txd = engineLoadTXD("added_models/"..modelTable.modelName.."/"..modelTable.modelName..".txd") engineImportTXD(txd, modelTable.currentID) local dff = engineLoadDFF("added_models/"..modelTable.modelName.."/"..modelTable.modelName..".dff") engineReplaceModel(dff, modelTable.currentID) elseif getElementModel(source) == modelTable.currentID then return end setElementModel(source, modelTable.currentID) outputDebugString('Модели "'..modelTable.modelName..'" присвоен ID: ' ..modelTable.currentID) end -
Some vehicles "engineRequestModel" features
DarkStalker30 replied to DarkStalker30's topic in Скриптинг
Yep, sorry. He just asks me for write original post on russian. His answer: 1) 409 - work, "new_car" - don't. local vehicleSirens = { ["new_car"] = {count = 2, sirens = { [1] = {x = -0.5, y = 1.5, z = 0.7, r = 255, g = 0, b = 0}, [2] = {x = 0.5, y = 1.5, z = 0.7, r = 0, g = 0, b = 255} }}, [409] = {count = 2, sirens = { [1] = {x = -0.5, y = 1.5, z = 0.7, r = 255, g = 0, b = 0}, [2] = {x = 0.5, y = 1.5, z = 0.7, r = 0, g = 0, b = 255} }} } function setSomeCoolThingsForVehicle(vehicle) if vehicleSirens[model] then outputDebugString('adding sirens, model: '..model) addVehicleSirens(vehicle, vehicleSirens[model].count, 5, false, false, false) for number, siren in ipairs(vehicleSirens[model][sirens]) do setVehicleSirens(vehicle, number, siren.x, siren.y, siren.z, siren.r, siren.g, siren.b) end end end 2) ["new_tt"] = {modelName = "towtruck2", parentID = 525, currentID = nil} -
Some vehicles "engineRequestModel" features
DarkStalker30 replied to DarkStalker30's topic in Скриптинг
Без проблем. Есть engineRequestModel, использую его для создания нового транспорта на основе старого. У таких моделей две проблемы: 1) Сирены автоматически не добавляются от модели-родителя, через addVehicleSirens() тоже не хотят нормально работать, у них есть только звук. Проверял на базовых моделях - функция работает на сервере. Ставил flag360 = true и checkLosFlag = false, применял сирены на стороне сервера и стороне клиента - всё равно не помогло. Есть ли вариант как-то всё-таки выставить их (без какой-либо новописной системы)? 2) При добавлении нового транспорта у него не работает по умолчанию тягание всяких частей кузова (эвакуатор, бульдозер, погрузчик и т.д.). Можно ли это как-то реализовать? Спасибо -
Hello everyone, sorry if my english bad. I did a script that allows to use new models throw the "engineRequestModel". It works good for replace, but I found some problems. First, I thought that if I use a parent ID from car with sirens, it will apply sirens on changed model. It didn't - so I tried to use addVehicleSirens(). It didn't work too - I have only a sound of sirens, but not them visual. On base non-changed models it works okay. I tried to set their positions on server and on client side, and set flag360 = true and checkLosFlag = false, but it still didn't help. Any ideas about fix that (except creating new sirens system)? Second, on new models doesn't work "up" and "down" abilities (dozer, towtruck, forklift etc.). Is any way to fix that? P.S. I understood that new models have new ID's, but I still need to fix this problems. Thanks in advance!
-
Hello everyone, again I'm asking help, hope u can do it I'm creating system of interiors and what I want: two (or more) players using the marker to enter, and server does calculations for all of them throw one event. Here code I have: Client: addEventHandler("onClientResourceStart", resourceRoot, function() bindKey("lalt", "down", function(key, state) local isReadyForUseMarker = getElementData(localPlayer, "player.activeMarker") if isElement(isReadyForUseMarker) and (getElementType(isReadyForUseMarker) == "marker" or getElementType(isReadyForUseMarker) == "pickup") then triggerServerEvent("teleportByMarker", localPlayer) end end) end) Server for teleport: addEvent("teleportByMarker", true) addEventHandler("teleportByMarker", root, function() if not client then return end local marker = getElementData(client, "player.activeMarker") if isElement(marker) and (getElementType(marker) == "marker" or getElementType(marker) == "pickup") then local x = getElementData(marker, "teleport.destinationX") local y = getElementData(marker, "teleport.destinationY") local z = getElementData(marker, "teleport.destinationZ") local world = getElementData(marker, "teleport.destinationWorld") local rotation = getElementData(marker, "teleport.destinationRotation") local dimension = getElementData(marker, "teleport.destinationDimension") if x and y and z and world and dimension and rotation then player = client setElementData(player, "player.activeMarker", false) fadeCamera(player, false) toggleAllControls(player, false) setElementFrozen(player, true) setTimer(function () triggerClientEvent(player, "toggleServerHud", player) end, 900, 1) setTimer(function () setElementInterior(player, world, x, y, z) setElementRotation(player, 0, 0, rotation) setElementDimension(player, dimension) end, 1500, 1) setTimer(function () setCameraTarget(player) fadeCamera(player, true) setTimer(function () triggerClientEvent(player, "toggleServerHud", player) setElementFrozen(player, false) toggleAllControls(player, true) end, 900, 1) end, 1500, 1) else outputDebugString('Not full list of arguments for TP!') end else outputDebugString('Triggered event for TP, but player has no data about marker.') end end) It works great for one player, but if many players try to enter at the same time, it breaks and do the code only for one player. How can I parallel this code for all players, which want to enter?
-
How to use client events on player's join
DarkStalker30 replied to DarkStalker30's topic in Scripting
And big thanks for all this explains, it helps me very much -
How to use client events on player's join
DarkStalker30 replied to DarkStalker30's topic in Scripting
YES! THANKS VERY MUCH IT WORKS! Can I ask some questions else? 1. Can I'll write to your's PM for some questions in future? Looks like you are advanced user and can help with many problems 2. Nothing go bad if I use "root" in client events? Because on wiki was written that root should not use, only in specific moments. I tried this too, but without new event it didn't work. And still thank you, that was very important message for best understanding of client triggers! -
Hello everyone! I have some server code: function onJoinLogin() local isClientReady = getElementData(source, "client.isready") local timer = true while not isClientReady or not timer do if timer then outputChatBox("Loading on client, wait...", source) isClientReady = getElementData(source, "client.isready") if not isClientReady then timer = false setTimer(function () timer = true end, 100, 1) end end end triggerClientEvent("setCameraForSpawn", source) triggerClientEvent("toggleHUD", source) setElementData(source, "player.isLogined", false) setElementData(source, "player.isActiveChar", false) outputChatBox("Login or reg, please", source) end addEventHandler("onPlayerJoin", root, onJoinLogin) And client code: local logoPath = "logo2.png" local screenWidth, screenHeight = guiGetScreenSize() local logoPNG = dxCreateTexture(logoPath) function createLogo() if logoPNG then dxDrawImage(screenWidth/10 * 9, screenHeight/6 * 5, 128, 128, logoPNG) else outputDebugString("Err logo!") end end addEventHandler("onClientRender", root, createLogo) addEvent("toggleHUD", true) addEventHandler("toggleHUD", root, function () outputDebugString('Toggle HUD!') setPlayerHudComponentVisible("radar", not isPlayerHudComponentVisible("radar")) end) addEvent("setCameraForSpawn", true) addEventHandler("setCameraForSpawn", root, function () outputDebugString('Set camera!') fadeCamera(true) setCameraMatrix(-2656.638, 373.576, 35.809, -2706.585, 376.137, 4.969) end) addEventHandler("onClientResourceStart", root, function () setElementData(root, "client.isready", true) end ) The problem is that client code workes on all players on server, when someone new joining. I tried to change "root" in client code on "localPlayer", "getLocalPlayer()", added "onClientResourceStart" and "set/getElementData()", but it's still don't work. And plus for first time for player camera don't work too, just a black screen. How can I fix it? p.s. New in Lua, but C++ programmer, I think I know some things about programming, but not here readed this topics: https://forum.multitheftauto.com/topic/118393-event-is-not-added-a-clientside-mta/ https://forum.multitheftauto.com/topic/88306-event-is-not-added-to-clientside/ https://forum.multitheftauto.com/topic/63280-server-triggered-clientside-event-but-event-is-not-added/
-
Change player's skin through the serverevent called from client
DarkStalker30 replied to DarkStalker30's topic in Scripting
LOL REALLY THANKS! I wrote the code at night and just forgot about that, Im stupid Thx for help everyone. -
Change player's skin through the serverevent called from client
DarkStalker30 replied to DarkStalker30's topic in Scripting
Already did, no any errors but didnt work. Debug is OK, right number in data. On spawn I have script for setting skin from data "player.skin" and it's working correct.