Jump to content

βurak

Members
  • Posts

    370
  • Joined

  • Last visited

  • Days Won

    21

Everything posted by βurak

  1. client: function snbl(posx, posy, posz) local bloqueo = playSound3D("blq.mp3", posx, posy, posz, false) setSoundMaxDistance(bloqueo, 20) end addEvent("playBLQ", true) addEventHandler("playBLQ", root, snbl) server: local posX, posY, posZ = getElementPosition(thePlayer) triggerClientEvent(root, "playBLQ", thePlayer, posX, posY, posZ) Can you pass the getElementPosition to the server side, and pass the x, y, z coordinates to the event as a parameter to the client side
  2. can you try this triggerClientEvent (root, "playBLQ" , root) you can also set the throttled option to false it can lower the volume playSound3D ( string soundURL, float x, float y, float z, [ bool looped = false, bool throttled = true ] )
  3. change root to thePlayer this argument asks which person to send it. root means everyone triggerClientEvent(thePlayer, "playBLQ", thePlayer)
  4. try using it like this function vhDam(loss) local playersLossHP = getVehicleOccupants(source) -- getVehicleOccupants returns a table for seat, player in pairs(playersLossHP) do --put this table in for loop local playerHealth = getElementHealth(player) --get the hp of the player inside the vehicle outputDebugString("Seat ID: "..seat.." Player Health: "..playerHealth) --print seat id and player's health end end addEventHandler("onVehicleDamage", root, vhDam)
  5. unfortunately you can't do this by default but you can run it on server side with "triggerServerEvent" and then pass the return value back to client side with "triggerClientEvent"
  6. βurak

    System cars

    here the function names and variable names are wrong house room See The Cars setTimer name is wrong set Timer --wrong setTimer --correct maybe you can show the rest of the code so we can help you
  7. maybe you can do it like this to accept the animation of others entering the car function blockExit(exitingPed, seat, jacked, door) if(isVehicleLocked(source)) then if(not jacked) then --cancel if car is not jacked cancelEvent() end end end addEventHandler("onVehicleStartExit", getRootElement(), blockExit)
  8. Can you try using the ignoredElement parameter processLineOfSight(px, py, pz, tx, ty, tz, true, true, true, true, true, false, false, false, localPlayer)
  9. I'm not sure but you can try this if(elementHit ~= localPlayer) then end
  10. use these functions attachElements -- to add an object to the player processLineOfSight -- to detect the object the player is standing on addCommandHandler --for the glue command
  11. there may be custom animations or they may have installed extra script to provide it. because setPedAnimation always allows 1 animation and the player stays frozen (except for walking animations) you can use 3ds max to create custom animations and use "engineLoadIFP" function to load this custom animation. if you're going this way
  12. I tested your idea, I guess it doesn't seem possible at the moment
  13. not sure but here mta function name is used try changing it function spawnPlayer(player) -- <-- mta spawn function if not (player == nil) then local pdata = savePlayerToData(player) local x,y,z = unpack(pdata["lastposition"]) spawnPlayer(player,x,y,z,0,pdata["skin"],0,0) fadeCamera(player, true) setCameraTarget(player, player) end end
  14. you can limit it by using root and using if command actually so you can handle it in a single eventhandler The nil error could possibly be because mark1 has not been created yet example: function markerHandler(hitElement, matchingDimension) if(getElementType(hitElement) == "player") then if(source == mark1) then --codes here for mark1 end if(source == mark2) then --codes here for mark2 end end end addEventHandler("onClientMarkerHit", root, markerHandler)
  15. it seems you haven't started the "bone_attach" script
  16. json returns a string type, so when saving, we should do it as VARCHAR in mysql, I'm not sure, but this string may be equivalent to mysql example: addCommandHandler("weap", function(player) local weapon = '[{ "27": 1500, "22": 1500, "28": 1500 } ]' --As you can see here json data is string giveWeaponsFromJSON(player, weapon) end) You can check the return value of the functions you use to distinguish it from the wiki, for example, the getPlayerName function returns a string on success. --here string getPlayerName ( player thePlayer ) likewise the setPlayerName function takes a string of data --here bool setPlayerName ( player thePlayer, string newName ) so the player's name is always string By looking at the return values of the functions you use, you can understand what should be INT and what should be VARCHAR.
  17. Try using the giveWeaponsFromJSON function inside the "onPlayerSpawn" event other than that make sure the column type is VARCHAR and has sufficient length To test whether the weapon gives or not, you can enter the column manually [{ "27": 1500, "22": 1500, "28": 1500 } ] Apart from that, I tested both functions on my own computer, there is no problem.
  18. I couldn't see an error here. Is the weapon column empty when you exit? Is there any error in the debugscript? You give the weapons when the player spawns, right? or maybe there is a error elsewhere
  19. If you don't give a slot to getPedWeapon, it will return the weapon you have. so specify the slot you will get getPedWeapon ( ped thePed, [ int weaponSlot = current ] ) you can use JSON to save the weapons in a mysql column You can create an inventory column in mysql and then you can use convertWeaponsToJSON at game exit. When you spawned, you can give weapons using giveWeaponsFromJSON --this part will be executed when the player exits the game function convertWeaponsToJSON(player) local weaponSlots = 12 --up to which slot the weapons will be saved local weaponsTable = {} --a table to temporarily store weapons for slot=0, weaponSlots do local weapon = getPedWeapon(player, slot) local ammo = getPedTotalAmmo(player, slot) if (weapon > 0 and ammo > 0) then if(weapon == 37) then --for ammo increase bug in this flamethrower ammo = ammo/10 end weaponsTable[weapon] = ammo --create a reference to the table with the weapon id and ammo amount end end return toJSON(weaponsTable) --return table as json end --to give weapons from mysql table when this player spawn (just one time) function giveWeaponsFromJSON(player, weapons) if (weapons and weapons ~= "") then takeAllWeapons(player) --take all weapons before the player. To avoid the ammo increase bug for weapon, ammo in pairs(fromJSON(weapons)) do --convert json format to table and load weapons into player if (weapon and ammo) then giveWeapon(player, tonumber(weapon), tonumber(ammo)) --give weapon to player end end end end
  20. INSERT creates a column from scratch in mysql, you can add a new column using this when the player is new registration The _Query function can be a special function where the result is returned in a single function to write less code. There is no difference between the two.
  21. I'm not sure, but can you try to delete the comma at the end of the interior in the query? --here local sendInfo = exports.mysql:_Query("UPDATE characters SET x=?, y=?, z=?, money=?, health=?, dimension=?, interior=? WHERE cuenta=?", x, y, z, money, health, dimension, interior, accName)
  22. you don't get the account name, you compare it directly with the player's account, for this, get the account name with getAccountName in the same way, change the playerAccount to accName in the query you sent. function recordarData() local playerAccount = getPlayerAccount(source) if(playerAccount) then if(isGuestAccount(playerAccount)) then return end end local x, y, z = getElementPosition(source) local money = getPlayerMoney(source) local health = getElementHealth(source) local dimension = getElementDimension(source) local interior = getElementInterior(source) local accName = getAccountName(playerAccount) --get player's account name to compare in mysql --Use dbQuery instead of _Exec --replace this with account name local sendInfo = exports.mysql:_Query("UPDATE characters SET x=?, y=?, z=?, money=?, health=?, dimension=?, interior=?, WHERE cuenta=?", x, y, z, money, health, dimension, interior, accName) if (sendInfo) then iprint("Data saved") else iprint("Error saving") end end addEventHandler("onPlayerQuit", getRootElement(), recordarData)
  23. hmm can you try to delete the break command for _,column in ipairs(setData) do setPlayerMoney(source, column["money"]) --get player's money from mysql and set Using: column["column name"] end
  24. I'm not sure, but you can do it this way, the onPlayerLogin event is suitable for this job, you can transfer the data to the game when the player logs in function setData() local playerAccount = getPlayerAccount(source) if(playerAccount) then if(isGuestAccount(playerAccount)) then return end end local accName = getAccountName(playerAccount) -- get player account name local setData = exports.mysql:_Query("SELECT * FROM characters WHERE name=? LIMIT 1", accName) -- Retrieve all column data with account name accName if(setData) then --if successful? if(#setData > 0) then -- if table size is greater than 0 for _,column in ipairs(setData) do setPlayerMoney(source, column["money"]) --get player's money from mysql and set Using: column["column name"] break --leave the for loop immediately when it has set all the data end end end end
  25. You can use UPDATE for this, but make sure the player always has a column in the database. You can use insert once before. do it with a function in your code that uses dbQuery instead of exec because you're using exports I'm not sure function saveDataCharacter() local playerAccount = getPlayerAccount(source) -- get account of player who exited game if(playerAccount) then if(isGuestAccount(playerAccount)) then return end -- if guest account don't continue end local x, y, z = getElementPosition(source) local money = getPlayerMoney(source) local health = getElementHealth(source) --Use dbQuery instead of _Exec --name I'm not sure of the player's account name? local sendInfo = exports.mysql:_Exec("UPDATE characters SET x=?, y=?, z=?, money=?, health=? WHERE name=?", x, y, z, money, health, playerAccount) if (sendInfo) then iprint("Data saved") else iprint("Error saving") end end addEventHandler("onPlayerQuit", getRootElement(), saveDataCharacter)
×
×
  • Create New...