DarkStalker30
Members-
Posts
28 -
Joined
-
Last visited
Everything posted by DarkStalker30
-
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. -
Change player's skin through the serverevent called from client
DarkStalker30 replied to DarkStalker30's topic in Scripting
Previous and next codes working good, I'm spawning in dimension 0 on right coords and with normal camera. setElementDimension(client, 0) setElementData(client, "player.isCharCreator", false) setElementData(client, "player.sex", charTable[4]) if charTable[4] then setPedWalkingStyle(client, 118) else setPedWalkingStyle(client, 129) end setElementData(client, "player.skin", charTable[7]) local skin = tonumber(charTable[7]) setElementModel(player, skin) setElementData(client, "player.pame", charTable[8]) setElementData(client, "player.isCharCreator", false) spawnPlayer(client, 233.5927734375, -1278.25, 6.351, -100, 0, 0, 0) fadeCamera(client, true) setCameraTarget(client) From client: triggerServerEvent("endCreate", localPlayer) -
Change player's skin through the serverevent called from client
DarkStalker30 replied to DarkStalker30's topic in Scripting
setElementData(client, "player.isCharCreator", false)--working good setElementData(client, "player.sex", charTable[4])--working good if charTable[4] then setPedWalkingStyle(client, 118)--working too else setPedWalkingStyle(client, 129)--working too end setElementData(client, "player.skin", charTable[7]) local skin = tonumber(charTable[7]) setElementModel(client, skin)--didn't work -
I should have understood it by myself ? Very thx!
-
It's really working, very thx! But sometimes it's lagging and jetpack is on/off many times in a second. Can I fix it somehow?
-
So, I have a client-side event: addEventHandler("onClientKey", root, function (button,press) if button == "j" then triggerServerEvent("jetpackClicked", root) end end) And I have server-side code: addEvent("jetpackClicked", true) addEventHandler('jetpackClicked', getRootElement(), function ( root ) setPedWearingJetpack ( root, not isPedWearingJetpack(root) ) end) But it's not working because "root" is not a ped. How can I fix it?
-
Есть карта Vice City, загружается на сервер с помощью скрипта. Как можно её же запустить в Map Editor? Пробовал Import - ничего не пишет в ответ.
-
Благодарю, я разобрался, там нужен был другой ресурс (MTA-Stream этого же автора).