Jump to content

Clipper_

Members
  • Posts

    30
  • Joined

  • Last visited

Everything posted by Clipper_

  1. Clipper_

    Effect fix

    used your method, thanks
  2. Clipper_

    Effect fix

    Doesn't work. I just want to see the effect in dimension 0, not all dimensions
  3. Clipper_

    Effect fix

    I got a problem with created effects. In normal dimension I created an effect that is attached to the player's vehicle. The problem is that players from other dimensions can see it too moving around. Any idea how I can restrict the effects only for dimension 0? local attachedEffects = {} function getPositionFromElementOffset(element,offX,offY,offZ) local m = getElementMatrix ( element ) -- Get the matrix local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] -- Apply transform local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] return x, y, z -- Return the transformed point end function attachEffect(effect, element, pos) attachedEffects[effect] = { effect = effect, element = element, pos = pos } addEventHandler("onClientElementDestroy", effect, function() attachedEffects[effect] = nil end) addEventHandler("onClientElementDestroy", element, function() attachedEffects[effect] = nil end) return true end addEventHandler("onClientPreRender", root, function() for fx, info in pairs(attachedEffects) do local x, y, z = getPositionFromElementOffset(info.element, info.pos.x, info.pos.y, info.pos.z) setElementPosition(fx, x, y, z) end end ) local fire = {} function createCustomEffect(player, vehicle, value) if value then local x, y, z = getElementPosition(vehicle) if not fire[player] then fire[player] = createEffect("fire_bike", x, y, z, 0, 0, 0, 0, true) attachEffect(fire[player], vehicle, Vector3(0, 0, 0)) setElementDimension(fire[player], 0) end else if fire[player] then attachedEffects[fire[player]] = nil destroyElement(fire[player]) fire[player] = nil end end end addEvent("triggerCustomEffect", true) addEventHandler("triggerCustomEffect", root, createCustomEffect) The event is triggered in server when a player enters a vehicle, motorcycle in this case. Attaching functions are taken from 'MTA Wiki > Suggested functions function onPlayerVehicleEnter(vehicle, seat, jacked) if getElementModel(vehicle) == 463 then if seat == 0 then triggerClientEvent("triggerCustomEffect", source, source, vehicle, false) end end end addEventHandler("onPlayerVehicleExit", root, onPlayerVehicleEnter)
  4. The best solution I could implement is with predefined position. Although I have to create a database for those, which is not hard at all. The ped solution is similar with getGroundPosition function, eliminated from first try.
  5. I want to create a random supply drop script that moves a certain object from a position in the air to the ground position vertically. -- SERVERSIDE local object = {id = 1271, x = 1000, y = 1000, z = 200} function moveSupply(source, command) local box = createObject(object.id, object.x, object.y, object.z, 0, 0, 0) -- here it should be something that calculates 'ground' as the z coordonate of the ground object point moveObject(box, 10000, object.x, object.y, ground) -- etc end addCommandHandler("supply", moveSupply) . The problem is that there is no support for getting the specific ground position in serverside, only in clientside. Waiting an idea or any other method that can work.
  6. Solved with element data. Thanks
  7. Can you tell me how can I send the hat to client? In this way I can fix other bugs that are related to local player only.
  8. Big thanks to people that gave me ideas for creating this resource. Developped a mode where you can set/remove the hat, but in the real test, I've found this bug when aiming specific weapons that change your camera. Is there any event that can be called when player aims the weapon, in order to make the hat dissapear from screen? (serverside)
  9. Clipper_

    Santa Hat

    For Christmas I want to create a script which adds a Santa Hat on the head of the local player by a command. During the development, I had 2 ideas: 1. Replacing the model of an existing Hat cloth is impossible and leads to a game crash. MTA seem to not have support for clothes ID, only for texture replacement. 2. Positioning another small object (with replaced texture and model) on top of the player's head is another solution. Here, the problem is the position where the hat should be placed: getting the coordonates of the highest "bone" of the ped with getPedBonePosition leads to small changes through the vales, so the hat is not moving with the head like it should behave. If you have a solution for getting the position of any body part (in this case the head), it will be a big help I will comment with the code if needed.
  10. I finished my script, restricting some cases when player could have felt off the bike in another way. I request topic closed
  11. So, in my server i have configured "glue" script, which attach players to my vehicle. Recently, i found a bug that throws me away if I do backflips and if i have another player glued on. What i want to do is to force myself to not fall of when i do rotations and when i have someone glued on my bike
  12. I want to create a script that prevents the fall of the player from the bike while doing backflips and while having another player glued. The thing is it doesn't do what it is supposed to. function onClientRender() if (isElementAttached(localPlayer) == true) then local naElement = getElementAttachedTo(localPlayer) if (getElementType(naElement) == "vehicle") then if (getVehicleType(naElement) == "Bike" or getVehicleType(naElement) == "BMX" or getVehicleType(vehicle) == "Quad") then local driver = getVehicleOccupant(naElement, 0) if (driver) then local rX, rY, rZ = getElementRotation(naElement) --outputChatBox("Bike rotation: x = " .. rX .. " y = " .. rY .. " z = " .. rZ) if (rX > 90 and rX < 300) then setPedCanBeKnockedOffBike(driver, true) outputChatBox(getPlayerName(driver) .. " is fixed") else setPedCanBeKnockedOffBike(driver, false) outputChatBox(getPlayerName(driver) .. " is not fixed") end end end end end end addEventHandler("onClientRender", root, onClientRender)
  13. i tried this to custom weapon names local weaponlist = { [ 31 ] = "M4A1", } local weaponID = getWeaponNameFromID (weaponlist) it is good?
  14. Hello Guys! I wanna get the current weapon name of player and to draw it on my hud local weapon = getPedWeapon (getLocalPlayer()) local weaponID = getWeaponNameFromID (getLocalPlayer(), weapon) dxDrawText("Weapon: "..weaponID..".", (0.585)*sWidth, (0.087)*sHeight, (0.293)*sWidth, (0.263)*sHeight, tocolor (64, 64, 64, 255),1.4,"pricedown","left","top",false,false,false,true) only with line 1, it shows me the ID. then tried to convert the ID in Name by following function from line 2. TY
  15. The "debugscript" hadn't showed me some errors. By the way, thank you guys for your effort !!!
  16. ohh alright. thank you. what about a FPS counter?
  17. Any idea how to draw at the bottom right a Ping indicator by using dxDrawText? I mean, how can i port the player's ping to a text?
  18. In Wiki, there is a "piraterpg.money" and i though it is a acc name. anyway thx
  19. Hello here! I need some help. I need an advice. If I replace "gabriell" with "thePlayer" is the money saving for each player and not for my account? function onPlayerQuit ( ) -- when a player leaves, store his current money amount in his account data local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then -- if the player is logged in local playermoney = getPlayerMoney ( source ) -- get the player money setAccountData ( playeraccount, "piraterpg.money", playermoney ) -- save it in his account end end function onPlayerLogin (_, playeraccount ) -- when a player logins, retrieve his money amount from his account data and set it if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "piraterpg.money" ) -- make sure there was actually a value saved under this key (check if playermoney is not false). -- this will for example not be the case when a player plays the gametype for the first time if ( playermoney ) then setPlayerMoney ( source, playermoney ) end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) I wanna modify this script to convert it for a stat save (got a problem with this script)
  20. Ok thank you. Appreciate it . I will test it later.
  21. actually he has to put source or thePlayer instead of source, because (i'm guessing) that he wants to trigger that first function with source element and thePlayer as well when calling the function example local playeraccount = getPlayerAccount(source) or getPlayerAccount(thePlayer) well the replacement work. now i have problems with some lines function savePlayerData (thePlayer) local playeraccount = getPlayerAccount(thePlayer) if (playeraccount) then local isPlayerInClass = getPlayerTeam(thePlayer) if ( ( isPlayerInClass ) and not isGuestAccount( account ) ) then setAccountData(playeraccount, "save.Player.Class", getTeamName( isPlayerInClass )) end end end addEventHandler("onPlayerQuit", root, savePlayerData); addEventHandler("onPlayerLogout", root, savePlayerData); addEventHandler("onPlayerWasted", root, savePlayerData); function loadPlayerData (thePlayer) local playeraccount = getPlayerAccount(thePlayer) if (playeraccount) then local isPedInClass = getAccountData (playeraccount, "save.Player.Class") if ( ( isPedInClass ) and getTeamFromName( isPedInClass ) ) then setPlayerTeam(source, getTeamFromName( isPedInClass )) end end end addEventHandler("onPlayerQuit", root, loadPlayerData) addEventHandler("onPlayerLogout", root, loadPlayerData) addEventHandler("onPlayerWasted", root, loadPlayerData) addEventHandler ("onPlayerLogin",root, function() loadStats( getPlayerAccount(thePlayer)) end ) addEventHandler ("onPlayerQuit",root, function() saveStats( getPlayerAccount(thePlayer)) end ) addEventHandler ("onPlayerLogout",root, function() saveStats( getPlayerAccount(thePlayer)) end ) addEventHandler ("onPlayerWasted",root, function() loadStats( getPlayerAccount(thePlayer)) end ) function saveStats( Acc) for i = 69 , 79 do setAccountData(thePlayer, "stat."..i , getPedStat(thePlayer,i)) end end function loadStats(Acc ) for i = 69 , 79 do setPedStat(thePlayer, i, getAccountData(Acc, "stat."..i)) end end Console response: [2014-12-12 20:06:15] WARNING: stats\main_s.lua:2: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got number '22'] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:14: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got number '22'] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:43: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'setPedStat' [Expected element at argument 1, got nil] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'setPedStat' [Expected element at argument 1, got nil] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'setPedStat' [Expected element at argument 1, got nil] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'setPedStat' [Expected element at argument 1, got nil] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'setPedStat' [Expected element at argument 1, got nil] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'setPedStat' [Expected element at argument 1, got nil] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'setPedStat' [Expected element at argument 1, got nil] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'setPedStat' [Expected element at argument 1, got nil] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'setPedStat' [Expected element at argument 1, got nil] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'setPedStat' [Expected element at argument 1, got nil] [2014-12-12 20:06:15] WARNING: stats\main_s.lua:55: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] Well i am at beggining of scripting. I was searching in community, in wiki to solve it. Same things. I did a progress by saving the stats after ped is dead. But the stats are 0 after exiting or reconnecting. You can check this. Thank you again
  22. Or if I stop defaultstats and then i set the stats from admin panel, will it have the effect i want?
×
×
  • Create New...