Jump to content

idarrr

Members
  • Posts

    133
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by idarrr

  1. This is a simple Quiz code. /createquiz - To create a Quiz. /answer - To answer the Quiz. /deletequiz - To delete unanswered Quiz. Server Side code: theAnswer = nil function createQuiz(thePlayer, cmd, quiz, answer) if theAnswer then outputChatBox("You can't create a Quiz. Use /deletequiz first to delete previous Quiz.", thePlayer) return end if not quiz or not answer then outputChatBox("SYNTAX: /"..cmd.." [Question] [Answer]", thePlayer) return end theAnswer = answer outputChatBox("QUIZ: "..quiz.."?", root) outputChatBox("QUIZ: Use command /answer to answer the quiz.", root) end addCommandHandler("createquiz", createQuiz) function deleteQuiz () if theAnswer then theAnswer = nil outputChatBox("QUIZ: Quiz has been deleted.", root) end end addCommandHandler("deletequiz", deleteQuiz) function answerQuiz (thePlayer, cmd, answer) if not theAnswer then outputChatBox("QUIZ: There is no Quiz.", thePlayer) return elseif not answer then outputChatBox("SYNTAX: /"..cmd.." [Answer]", thePlayer) return end if answer == theAnswer then theAnswer = nil outputChatBox("QUIZ: "..getPlayerName(thePlayer).." win the Quiz!", root) outputChatBox("QUIZ: The correct answer is \""..answer..".\"", root) givePlayerMoney(thePlayer, 200) end end addCommandHandler("answer", answerQuiz)
  2. Maybe use setElementCollisionsEnabled to disable physical interaction between vehicle and an object.
  3. Try. cooldowns = {} local cooldowntime = 60000 -- Cooldown for 1 minute / 60 seconds function removeCooldown(thePlayer) if cooldowns[thePlayer] then cooldowns[thePlayer] = nil end end function weaponsKit() if cooldowns[source] then if isTimer(cooldowns[source]) then local remaining = getTimerDetails(cooldowns[source]) outputChatBox("#00ff00Cooldown remaining: ".. remaining/1000 .." seconds.",source, 255, 255, 255, true) return end end cooldowns[source] = setTimer(removeCooldown, cooldowntime, 1, source) local account = getPlayerAccount ( source ) local accName = getAccountName ( account ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then setElementData(source, "MAX_Slots", 200) setElementData(source, "M4", 1) outputChatBox("#00ff00Weapon VIP #ffffffitems.",source, 255, 255, 255, true) else outputChatBox("#ff0000[Error] #ffffffYou don't have VIP!",source, 255, 255, 255, true) end end addEvent("onWeaponKitTake", true) addEventHandler("onWeaponKitTake", getRootElement(), weaponsKit) function medicalKit() if cooldowns[source] then if isTimer(cooldowns[source]) then local remaining = getTimerDetails(cooldowns[source]) outputChatBox("#00ff00Cooldown remaining: ".. remaining/1000 .." seconds.",source, 255, 255, 255, true) return end end cooldowns[source] = setTimer(removeCooldown, cooldowntime, 1, source) local account = getPlayerAccount ( source ) local accName = getAccountName ( account ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then setElementData(source, "Medic Kit", 2) setElementData(source, "Morphine", 2) outputChatBox("#00ff00Medical VIP #ffffffitems.",source, 255, 255, 255, true) else outputChatBox("#ff0000[Error] #ffffffYou don't have VIP!",source, 255, 255, 255, true) end end addEvent("onMedicalKitTake", true) addEventHandler("onMedicalKitTake", getRootElement(), medicalKit)
  4. idarrr

    Question

    You can use onPlayerDamage. addEventHandler( "onPlayerDamage", root, function (attacker, weapon, bodypart, loss) if isElement(attacker) and getElementType(attacker) == "vehicle" then setElementHealth(source, 0) end end )
  5. Use getPlayerMoney, use this code to check if the player has enough money to pay. function hasEnoughMoney (thePlayer, amount) if isElement(thePlayer) and getElementType(thePlayer) == "player" then if amount and tonumber(amount) then local amount = tonumber(amount) if amount < 0 then return false end local money = getPlayerMoney(thePlayer) if money >= amount then return true end end end return false end Then when you need to check if the player has enough money, call the function. The first argument is a player element, the second argument is the amount of money you want to check. Example: if hasEnoughMoney(thePlayer, 30000) then -- If the player has $30,000 takePlayerMoney(thePlayer, 30000) -- Don't forget to take their money -- Your code to execute here -- end
  6. Variable thePlayer is not defined. Try this. function startUp() for k,v in ipairs ( getElementsByType ( 'player' ) ) do if exports["SADZcommands"]:isPlayerInTeam(v, "Criminals") then safeTable = createObject (1829 ,2580.619140625, 2328.5845703125, 17.222208404541) createBlipAttachedTo ( safeTable, 38, 3, 0, 117 , 0 , 255, 0, 99999.0 ) loadConfig() else outputDebugString("wrong") end end end addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ), startUp)
  7. Post your final code.
  8. addEventHandler('onPlayerJoin', root, function() local name = getPlayerName(source) setTimer( function() triggerClientEvent (root, "createNotification", root, "#FFffFFcsatlakozott a szerverre.", "simple", name) end, 1000, 1) end ) addEventHandler('onPlayerQuit', root, function(reason) local name = getPlayerName(source) triggerClientEvent (root, "createNotification", root, "#FFffFF"..reason, "simple", name) end ) Read more detail here about paramaters that are passing when event is triggered. https://wiki.multitheftauto.com/wiki/Event_system https://wiki.multitheftauto.com/wiki/AddEventHandler https://wiki.multitheftauto.com/wiki/OnPlayerQuit https://wiki.multitheftauto.com/wiki/OnPlayerJoin
  9. function startUp() for _, thePlayer in ipairs(getElementsByType("player")) do if exports.SADZconfirm:isPlayerInTeam( thePlayer, "Criminals") then safeTable = createObject (1829 ,2580.619140625, 2328.5845703125, 17.222208404541) createBlipAttachedTo ( safeTable, 38, 3, 0, 117 , 0 , 255, 0, 99999.0 ) loadConfig() else outputDebugString("wrong") end end end addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ), startUp)
  10. addEventHandler('onPlayerChangeNick', root, function(oldNick, newNick) triggerClientEvent (source, "createNotification", source, "Your Text", "simple", oldNick, newNick) end )
  11. I had this problem before, it seems that event doesn't trigger when player attack that vehicle, so you need to use onClientVehicleDamage.
  12. idarrr

    dx stuff

    local startX, startY = sWidth/2-204, sHeight/2-404 local width, height = 409, 809 dxDrawImage(startX, startY, width, height,...) -- Then when you want to draw text inside the image, use startX and startY as starting point so it works on all screen resolution -- This is example dxDrawText("Text here", startX, startY, startX+width, startY+height, tocolor(255,255,255,255), 1, "default", "center", "center" ) dxDrawText("Text here 2", startX, startY+400, startX+width, startY+height, tocolor(255,255,255,255), 1, "default", "center", "center")
  13. Server Side: function getTotalAccounts () local accounts = getAccounts() local totalaccounts = #accounts triggerClientEvent(client, "getTotalAccounts", client, totalaccounts) end addEvent("getTotalAccounts", true) addEventHandler("getTotalAccounts", root, getTotalAccounts) Client Side: triggerServerEvent("getTotalAccounts", localPlayer) function getTotalAccounts (totalaccounts) totalaccounts = tonumber(totalaccounts) end addEvent("getTotalAccounts", true) addEventHandler("getTotalAccounts", root, getTotalAccounts) addEventHandler("onClientRender", root, function () if totalaccounts then dxDrawText("Total Registered Accounts on Server: "..totalaccounts, 0, 0, 50, 10) end end ) setTimer( function () triggerServerEvent("getTotalAccounts", localPlayer) end, 60000, 0) -- Check every 1 minute
  14. Yeah, so i use something like this on my server. local handling = toJSON(getVehicleHandling(vehicle)) -- You can insert handling variable to db And when you need to get that handling data, use this. local handling = fromJSON(row.handling) -- This is an example, row.handling is from database for k, v in ipairs(handling) do setVehicleHandling(vehicle, k, v) end
  15. Yeah of course, because the sound is set to loop. Replace with this one. -- This sound will play once local sound = playSound("Night.mp3", false)
  16. Yeah that works. But checking every 3 seconds isn't good idea. The one I gave to you is working on me. But it seems that the timer doesn't sync with GTA time. So this is works perfectly on my localhost. local minDuration = getMinuteDuration() local _, timeminute = getTime() local minuteTimer = (61-timeminute)*minDuration function Nightmare() local hour, minute = getTime() if (hour == 22) then -- Only play the sound at 22 local sound = playSound("Night.mp3",true) outputChatBox( "Esta anocheciendo. . .", 80, 80, 200 ) end local minuteTimer = (61-minute)*minDuration setTimer(Nightmare, minuteTimer, 1) -- This will check the time every minute in game time end setTimer(Nightmare, minuteTimer, 1)
  17. local minDuration = getMinuteDuration() local _, timeminute = getTime() local minuteTimer = (60-timeminute)*minDuration function Nightmare() local gateTimer = getTime() if (gateTimer == 22) then -- Only play the sound at 22 local sound = playSound("Night.mp3",true) outputChatBox( "Esta anocheciendo. . .", 80, 80, 200 ) end setTimer(Nightmare, 60*minDuration, 1) -- This will check the time every minute in game time end setTimer(Nightmare, minuteTimer, 1)
  18. Might work. local minDuration = getMinuteDuration() local _, timeminute = getTime() local minuteTimer = (60-timeminute)*minDuration setTimer(Nightmare, minuteTimer, 1) function Nightmare() local gateTimer = getTime() if (gateTimer == 22) then -- Only play the sound at 22 local sound = playSound("Night.mp3",true) outputChatBox( "Esta anocheciendo. . .", 80, 80, 200 ) end setTimer(Nightmare, 60*minDuration, 1) -- This will check the time every minute in game time end
  19. Did you put that code on Server Side? Because it won't work on Client Side.
  20. -- Server Side code function setVehicleOriginalVelocity(thePlayer) local veh = getPedOccupiedVehicle(thePlayer) if veh then -- Make sure the player is in the vehicle local vehModel = getElementModel(veh) local originalVelocity = getOriginalHandling(vehModel)["maxVelocity"] setVehicleHandling(veh, "maxVelocity", originalVelocity) else outputChatBox("You are not in Vehicle!", thePlayer) end end addCommandHandler("setoriginalvel", setVehicleOriginalVelocity)
  21. idarrr

    can't store data

    Do you mean like this? -- create table contain the position and rotation of machine gun machineguns = { -- x, y, z, rotx, roty, rotz {-2861.9, 19.4, 15.83, 0, 0, 188}, {-2864.9, 19.4, 15.83, 0, 0, 188}, -- and more you can add it.. } function mg_pos() for _, v in pairs(machineguns) do createMG(v[1], v[2], v[3], v[4], v[5], v[6]) end end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), mg_pos)
  22. idarrr

    SetVihicleColor

    vehicles = {} -- Create 140 vehicles and set the color to red for i=1, 140 do local x = 1625+((i-1)*5) -- Create 5 point space of each vehicle local veh = createVehicle(451, x, 1831, 10.2, 0, 0, 0) setVehicleColor(veh, 255, 0, 0) table.insert(vehicles, veh) end -- Or if you want a separated function function setVehColor() for _, veh in pairs(vehicles) do setVehicleColor(veh, 255, 0, 0) end end
  23. idarrr

    can't store data

    No need to setElementData Server: function mg_pos() createMG(-2861.9, 19.4, 15.83, 0, 0, 188) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), mg_pos) function createMG(posX,posY,posZ,rotX,rotY,rotZ) local mg = createObject ( 356, 0,0,0) -- this is where the data will be stored (new line) local weapon_base = createObject ( 1897, posX,posY,posZ,rotX,rotY,rotZ) local weapon = createObject ( 356, 0,0,0) attachElements ( weapon, weapon_base, -0.55, 0, 0.75, 0, 0, 0) setElementAlpha(weapon_base, 0) setTimer ( event, 500, 1, weapon_base ) end function event(weapon_base) triggerClientEvent("createRealWeapon", root, weapon_base) end
×
×
  • Create New...