Jump to content

ds1-e

Scripting Moderators
  • Posts

    636
  • Joined

  • Days Won

    8

Everything posted by ds1-e

  1. ds1-e

    Trigger/tables

    By the way i should add "delay" (getTickCount()/setTimer), protection for events which player can trigger manually? I'm talking about events which send small count of data. Just wanna be sure if this can overload server too.
  2. lmao. This should be custom or standard animation?
  3. I cannot, i am sure that it will change also speed of other actions.
  4. Hey. I would need an idea how i could make faster sprinting by holding space (not tapping). I mean the "fast sprint" glitch. - OnClientKey/bindKey, but what later? I don't have any idea how it could be done, maybe a loop?
  5. I would try, i'm sure by following your advice i could do that I just need a point to start off, and some more time (besides that, i'm doing a lot of other things, i'm asking about that, because i will need it in nearest future.)
  6. Where exactly i should use int loop, or we're about changing it in this function? function forgetNonExistingPeds() local checkedcount = 0 while true do for element,ped in pairs(attached_ped) do if not isElement(ped) then clearAttachmentData(element) end checkedcount = checkedcount+1 if checkedcount >= 1000 then coroutine.yield() checkedcount = 0 end end coroutine.yield() end end
  7. Hey. I would like to integrate bone attach with my gamemode, and also improve code a bit. First of all, question about meta of bone attach. <script src="bone_attach.lua" /> <script src="bone_attach_c.lua" type="client" cache="false" /> <script src="attach_func.lua" /> <script src="attach_func.lua" type="client" cache="false" /> <script src="bone_pos_rot.lua" type="client" cache="false" /> If script doesn't have defined type, then by default it's server/shared? So i thought about those ways. 1. Use more locals - following this performance tips? 2. Replace onClientRender to render events by IIYAMA - probably this should help a little bit though. 3. Any other way which i don't know about?
  8. Hey, I wanna say that it works flawless. I know how to get it for player, but what about vehicle?
  9. Hey, i would need to check if ped is not on ground - if so, then i want move him to the ground. I will use this function as first, but what later? https://wiki.multitheftauto.com/wiki/IsPedOnGround Is there any way to get "closest" ground position?
  10. ds1-e

    Trigger/tables

    Probably i would need to test all the ways. If i would keep ammo value synced only on client, and want to send it back when player quit within 'OnClientResourceStop', it should work? And what about if player lost connection, trigger will be sent? Related topic: I didn't test it yet, because i need to finish other things, but i want to be sure, for future.
  11. ds1-e

    Trigger/tables

    Oh well What if, i would change them that way: OnClientPlayerWeaponFire -> change data in client side table, so it will be actual ammo in HUD. OnPlayerWeaponFire -> change data in server-side table. Without any triggers. That way may cause any problems, f.e: other value on client, and other value on server side table?
  12. ds1-e

    Trigger/tables

    What about player ammo, which also counts as an item, and count of it change after each time when player shoot. I'm just wondering how this should be done for custom data system. This how it's looks with elementData: -- client function decreaseWeaponAmmo(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) if source == getLocalPlayer() then local weapon = getElementData(getLocalPlayer(), "player:selected") if playerWeapons[weapon] then if getElementData(getLocalPlayer(), playerWeapons[weapon].ammo) > 0 and getPedWeaponSlot(getLocalPlayer()) == playerWeapons[weapon].wpSlot and getElementData(getLocalPlayer(), "player:weapon_1") == weapon then setElementData(getLocalPlayer(), playerWeapons[weapon].ammo, getElementData(getLocalPlayer(), playerWeapons[weapon].ammo) - 1 or 0) end end end end addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), decreaseWeaponAmmo) 1. From server, onPlayerWeaponFire, send back to player, refresh ammo in HUD/GUI. 2. From client, onClientPlayerWeaponFire - refresh ammo in HUD/GUI, send back to server. 3. Both, onClientPlayerWeaponFire and onPlayerWeaponFire. And also a question related with onPlayerWeaponFire, wiki says: This does not trigger for projectiles, melee weapons, or camera. This event works only with weapons which have enabled bullet sync. I'm not sure, but does RPG counts to those weapons which trigger this server event?
  13. Should work? -- default --> add player to table, after his login on https://wiki.multitheftauto.com/wiki/OnPlayerLogin -- in case of resource restart --> loop: getElementsByType, check if they are logged in (isGuestAccount function), insert logged in players to table. And so, if isn't root then this will be a little bit better for performance?
  14. ds1-e

    Trigger/tables

    I'm not even thinking about browser. Just simple things: text labels, edits, checkboxes, comboboxes. What about adding server-side check if any trigger happend when editing, and if so, inform about that client, and block incoming trigger with data update?
  15. ds1-e

    Trigger/tables

    Hi. I'm creating custom data system based on tables client/server side (player interface/storing values which should be same for all of the players), trigger (changing those data, to keep them synced for all of players, in nearly all cases), and sqlite. (storing data after player quit; i'll implement soon). As i said in past that i don't wanna use setElementData at all i decided to do custom system for this. I have two questions, which are important, to avoid any bugs. 1. Player inventory/items. - Let's say i keep player items synced with client and server side. For GUI and for server in case of player death. Will be safer and better to change values by server only, and not by 1. client, 2. server? In that way - like wiki says, it's better if server would do it?: --> Synced item --> triggerServerEvent to change it... Value on server side: sync complete --> Send triggerClientEvent back to player, refresh item count in GUI. And not like that: --> Synced item --> Change item count on client side GUI... --> Send triggerServerEvent to sync it on server. 2. Refreshing GUI for group of players. To refresh GUI for players in same colshape, i should do it after sync item value on server-side? @IIYAMA i believe you can answer my questions
  16. ds1-e

    Scaling

    Hey, i come across problem of scaling things. I am looking for best way to make it. Maybe there's some other ways to do it, excluding this: 1. local screenX, screenY = guiGetScreenSize() -- screenX * size/base X The way above isn't good, on less resolutions some things are incorrect. 2. local screenX, screenY = guiGetScreenSize() local baseX = 1280 local zoom = 1 local minZoom = 2 if screenX < baseX then zoom = math.min(minZoom, baseX/screenX) end This way probably is best so far, the problem is that i use it most likely in bad way, because positions for GUI aren't correct. 3. Or there's another, good way? Or i am doing this incorrect.
  17. ds1-e

    Acl vehicle

    Function isPlayerInGroup most likely doesn't exist. If we're about ACL maybe you wanted this? bool isObjectInACLGroup ( string theObject, aclgroup theGroup ) https://wiki.multitheftauto.com/wiki/IsObjectInACLGroup
  18. Maybe you could check it again, and to be sure it should be client-side. You can paste code again? I tested it by myself, and it work somehow, not perfectly but it did the basic job. As far i remember you should also replace following objects with custom transparent model. 356 347 358 355 335 322 353 339 357 349 Scan: https://www.virustotal.com/#/file-analysis/MTAyNWY5MzQ5ZjA5YjcyMTZkNmNkNGFhNjI0ZGI5ZjU6MTU1NjExNzU3OA== Download: https://www.mediafire.com/file/rk9bm7r2oo8gq6w/transparent.rar/file
  19. triggerServerEvent: Returns true if the event trigger has been sent, false if invalid arguments were specified or a client side element was a parameter. I'll show you an example, to make things easier for you. It wasn't tested, but should work. -- clientside local first_variable = "Empty" local second_variable = "Nothing here" triggerServerEvent("onPlayerUseItem", getLocalPlayer(), first_variable, second_variable) -- serverside function onPlayerUseItem(first_arg, second_arg) local player = source -- event source outputChatBox(first_arg..", "..second_arg, player) end addEvent("onPlayerUseItem", true) addEventHandler("onPlayerUseItem", getRootElement(), onPlayerUseItem) This example shows how to get data from trigger, and if you want you can save it to variable.
  20. Hey. Some weird thing. I wanted to make songs play in login panel randomly, but it doesn't work. It plays only 3 songs, but in total there's 7 songs. local loginSounds = {"music1", "music2", "music3", "music4", "music5", "music6", "music7"} function onClientResourceStart() local random = math.random(1, 7) loginMusic = playSound("files/"..loginSounds[random], true, false) end addEventHandler("onClientResourceStart", resourceRoot, onClientResourceStart) I didn't even count how much times i reconnected to check if all songs are playing. I don't know if it's my code mistake, but after restarting script all songs can play, not only 3 of them.
  21. Check, should work. If not, let me know. A example code. -- clientside local screenWidth, screenHeight = guiGetScreenSize() local ped1 = createPed(7, -2430.74902, -590.24249, 131.80247) function onClientRender() local ped_health = getElementHealth(ped1) dxDrawText(ped_health, screenWidth * 0.800, screenHeight * 0.500, screenHeight * 0.060, screenHeight * 0.060, tocolor(255, 255, 255, 255), 0.75, "default-bold", "left", "top", false, false, false, false, false) end addEventHandler("onClientRender", getRootElement(), onClientRender)
  22. Clientside scripts which have cache="false" will be not saved in player cache, but in RAM. So, still you can use them. I don't really understand you, can you be a more specific? You need to hide scripts/files or something else?
  23. My mistake, this loop is ok. Are you sure that id of replaced objects in condition are correct?
×
×
  • Create New...