Jump to content

βurak

Members
  • Posts

    377
  • Joined

  • Last visited

  • Days Won

    22

Everything posted by βurak

  1. 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
  2. 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.
  3. 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)
  4. 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)
  5. 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
  6. 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
  7. 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)
  8. There is no reason for you to do this check for the combo box, if you want to check it with the player's input, it may work, but I'll give an example anyway. A2 = string.gsub(A2, "%s+", "") -- delete all spaces for A2 if(string.len(A2) > 0) then --if A2 is greater than 0 characters -- codes here end you can only use this in variables where you use guiComboBoxGeItemText function
  9. try using string.len and string.gsub local text = "" -- empty text text = string.gsub(text, "%s+", "") -- delete all spaces if(string.len(text) > 0) then --if text is greater than 0 characters -- codes here end
  10. yes now the problem is really solved thanks tut
  11. I am using the hero dff exporter with max 2009 version
  12. hello, I painted this object with vertex painting, but when the players walk on this object and take a jetpack, the light changes, and it also changes at different camera angles. What is the reason for this?
  13. you can use a table for this, when you bring back the player's health, you mark it as true in this table, you change it to false when it spawns again so it only uses knocked down players setPlayerKnockDown(player, true) --mark the player as knocked down so he can use the command local isPlayersKnockDown = {} function setPlayerKnockDown(player, condition) isPlayersKnockDown[player] = condition end function revivir(source) if (si==1) and (cancelText==nil) then if(isPlayersKnockDown[source]) then -- only downed players can use spawnPlayer(source, 2041.3568115234,-1409.2247314453,17.1640625,178) si = 0 takePlayerMoney(source, 1000) takeAllWeapons(source) outputChatBox("...", source, 0, 255, 0) setPlayerKnockDown(source, false) --set false when the player spawns so he can't use it again end end end addCommandHandler("test", revivir) addEventHandler("onPlayerQuit", root, function() isPlayersKnockDown[source] = nil -- clean from memory end )
  14. give the source player to the timer like this function revivir1() revivir = 1 cancelText = nil setPedAnimation(source, ".", ".", -1, false, false, false, true) outputChatBox (".", source, 255, 0, 0) setTimer(function(source) -- Pass source player into timer si = 1 cancelText = cancelText if (cancelText==nil) then outputChatBox(".", source, 255, 0, 0) ------This is the wrong text end end, 600, 1, source) -- Pass source player into timer end addEvent("sistemarev", true) addEventHandler("sistemarev", root, revivir1)
  15. it worked, thanks ? i think, considering the size of the facility, 300 units seem to be enough
  16. here thePlayer argument is invalid use for loop to add all players addEventHandler("onResourceStart", resourceRoot, function() for _,thePlayer in ipairs(getElementsByType("player")) do bindKey(thePlayer, "space", "down", pararAnim) end end ) function prueba(thePlayer) setPedAnimation(thePlayer, "finale", "fin_let_go", -1, false, false, false, false) end addCommandHandler("prueba", prueba) function pararAnim(thePlayer, key, keyState) setPedAnimation(thePlayer) end if you want to add for single player you can put it inside prueba command i don't know how to use it
  17. how do you use it can you show more?
  18. Hello, I am modeling a facility. I have a problem with the model that appears here. The object becomes invisible because it is a little big, how do I solve this problem, thanks size of the object
  19. you can debug it with outputDebugString to find out outputDebugString(Hungers) outputDebugString(Thirsts)
  20. change with result if result and #result > 0 then return end
  21. There is actually no player parameter here, can you edit both places like this? addEvent("unload_vehicles",true) local function unload_vehicles(player, veh) setElementFrozen(veh,true) toggleControl(player,"enter_exit",false) setTimer(function(player,veh) local cars = getAttachedElements(veh) for i,v in pairs(cars) do destroyElement(v) end setElementData(veh,"loaded",false) --exports.global:giveMoney(plr,1500) givePlayerMoney(player, 1500) outputChatBox("قدت السيارات وحصلت على 1.500 دولار , يمكنك الرجوع واخذ مهمه جديده",player,255,255,255,true) setElementFrozen(veh,false) toggleControl(player,"enter_exit",true) end,5000,1, player, veh) end addEventHandler("unload_vehicles",resourceRoot,unload_vehicles) local function unload_vehicles(plr,md) if plr ~= localPlayer or not md then return end if source ~= checkpoint then return end local veh = getPedOccupiedVehicle(plr) triggerServerEvent("unload_vehicles",resourceRoot,veh, plr) destroyElement(checkpoint) destroyElement(blip) checkpoint = nil blip = nil end addEventHandler("onClientMarkerHit",resourceRoot,unload_vehicles)
  22. Try changing 0 to -1 for dbPoll function getpaccount (_,account) local AccName = getAccountName(account) local Setpname = setPlayerName(source,tostring(AccName)) local AccData = dbQuery(AccDatacallback(), db,"SELECT * FROM stats WHERE Account=? LIMIT 1", AccName) function AccDatacallback(AccData) local result = dbPoll( AccData, -1 ) --this end if(AccData) then if(#AccData > 0) then return end end local ID = getFreeID() local SetData = dbExec(db,"INSERT INTO stats (ID,Account) VALUES (?, ?)",ID, AccName) end addEventHandler("onPlayerLogin",root, getpaccount)
  23. addEvent("unload_vehicles",true) local function unload_vehicles(veh) setElementFrozen(veh,true) toggleControl(client,"enter_exit",false) setTimer(function(plr,veh) local cars = getAttachedElements(veh) for i,v in pairs(cars) do destroyElement(v) end setElementData(veh,"loaded",false) --exports.global:giveMoney(plr,1500) givePlayerMoney(plr, 1500) outputChatBox("قدت السيارات وحصلت على 1.500 دولار , يمكنك الرجوع واخذ مهمه جديده",plr,255,255,255,true) setElementFrozen(veh,false) toggleControl(plr,"enter_exit",true) end,5000,1, plr) end addEventHandler("unload_vehicles",resourceRoot,unload_vehicles) can you change this line like this, try with normal functions
  24. I don't know this error maybe you can ask someone else
  25. I did not know that. You're welcome. anytime ?
×
×
  • Create New...