Jump to content

Walid

Members
  • Posts

    1,491
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Walid

  1. All what you need is: isPedInVehicle() getPedOccupiedVehicle() isElementInWater() getElementPosition() setElementPosition() getWaterLevel()
  2. Walid

    Output problem

    Here is all what you need function staffcommand (player, command) if player and isElement(player) and getElementType(player) == "player" then if (isPedInVehicle(player) then return outputChatBox("You cannot use this command inside a vehicle.", player, 255, 0, 0, true) end local account = getPlayerAccount(player) if account and not isGuestAccount(account) then local accName = getAccountName(account) if ( isObjectInACLGroup ("user."..accName, aclGetGroup ("Admin"))) then setElementPosition ( player, 3749.9094238281, -194.06666564941, 5.3276481628418 ) else outputChatBox("Only staff can use this command.", player, 255, 0, 0) end end end end end addCommandHandler("staffland", staffcommand) @CodyL : 1) You already checked if the player is inside a vehicle or not (using isPedInVehicle) so you don't need to use (getPedOccupiedVehicle). 2) And here you are checking if it's a guest account ??? it should be "if not isGuestAccount" .
  3. working fine for me , try to use sth like this local count = 0 function getElementsWithinColShapes() local vehicles = getElementsByType ("vehicle") for i, veh in pairs (vehicles) do if (isElementWithinColShape(veh, col)) then count = count + 1 end end return count end
  4. @DonOmar , You need to respect others here. he tried to help you.
  5. All what you need is : "onPlayerContact" -- Event
  6. All what you need is: table.insert() table.sort()
  7. Here is all what you need: local timersTable = {} local islandCOL = createColRectangle (3528.18994, -326.39496, 1000, 300 ) function Island (player) if player and isElement(player) and (getElementType(player) == "player") then local player = (isPedInVehicle(player) and getVehicleController (getPedOccupiedVehicle (player))) or player local account = getPlayerAccount(player) if account and not isGuestAccount(account) then local accName = getAccountName(account) if ( isObjectInACLGroup ("user."..accName, aclGetGroup ("Admin"))) then return false end if eventName == "onColShapeHit" then local timer = getAccountData(account, "timer") -- get the timer using getAccountData if (timer) then timersTable[player] = setTimer(killPed, tonumber(timer), 1, player) else if not(timersTable[player]) then timersTable[player] = setTimer(killPed, 20000, 1, player) end end outputChatBox("You have entered Staff Island, you have 20 seconds to leave or you'll be killed.", player, 255, 0, 0, true) elseif eventName == "onColShapeLeave" then if isTimer(timersTable[player]) then local remaining = getTimerDetails(timersTable[player]) setAccountData(account, "timer", tonumber(remaining)) killTimer(timersTable[player]) timersTable[player] = nil outputChatBox("You have left the area.", player, 0, 200, 0) end end end end end addEventHandler ( "onColShapeHit", islandCOL, Island) addEventHandler ( "onColShapeLeave", islandCOL, Island) addEventHandler( "onPlayerWasted", getRootElement( ), function() local account = getPlayerAccount(source) if account and not isGuestAccount(account) then if isTimer(timersTable[source]) then killTimer(timersTable[source]) timersTable[source] = nil setAccountData(account, "timer",false) end end end ) function save () local playerAccount = getPlayerAccount ( source ) if (isTimer(timersTable[source])) then local remaining = getTimerDetails(timersTable[source]) if playerAccount and not isGuestAccount(playerAccount) then setAccountData(playeraccount, "timer", tonumber(remaining)) killTimer(timersTable[source]) -- kill the timer timersTable[source] = nil end end end addEventHandler ("onPlayerQuit", root, save )
  8. bro it's only 20 seconds , anyways you can use setAccountData() getAccountData() For more information , Check my answer, they already asked the same question Here
  9. So all what you need is: getTimerDetails () setElementData() getElementData()
  10. The timer will be killed when you leave the colship. read my code again
  11. Walid

    save money

    function playerQuit() local playeracc = getPlayerAccount( source ) if (playeracc) and not isGuestAccount(playeracc) then local playercash = tonumber(getPlayerMoney( source )) setAccountData(playeracc, "cash", playercash) end end addEventHandler( "onPlayerQuit", getRootElement(), playerQuit ) addEventHandler( "onPlayerLogout", getRootElement(), playerQuit ) function playerLogin(_,account) local money = getAccountData(account, "cash") if money then setPlayerMoney(source, tonumber(money)) end end addEventHandler( "onPlayerLogin", getRootElement(), playerLogin )
  12. Done fixed local timersTable = {} local islandCOL = createColRectangle (3528.18994, -326.39496, 1000, 300 ) function Island (player) if player and isElement(player) and (getElementType(player) == "player") then local player = (isPedInVehicle(player) and getVehicleController (getPedOccupiedVehicle (player))) or player local account = getPlayerAccount(player) if account and not isGuestAccount(account) then local accName = getAccountName(account) if ( isObjectInACLGroup ("user."..accName, aclGetGroup ("Admin"))) then return false end if eventName == "onColShapeHit" then if not(timersTable[player]) then timersTable[player] = setTimer(killPed, 20000, 1, player) outputChatBox("You have entered Staff Island, you have 20 seconds to leave or you'll be killed.", player, 255, 0, 0, true) end elseif eventName == "onColShapeLeave" then if isTimer(timersTable[player]) then killTimer(timersTable[player]) timersTable[player] = nil outputChatBox("You have left the area.", player, 0, 200, 0) end end end end end addEventHandler ( "onColShapeHit", islandCOL, Island) addEventHandler ( "onColShapeLeave", islandCOL, Island) addEventHandler( "onPlayerWasted", getRootElement( ), function() if isTimer(timersTable[source]) then killTimer(timersTable[source]) timersTable[source] = nil end end )
  13. Walid

    help

    Lol using 3 server names inside the same code :fp:, and you said that it's your code. function convert(player, cmd, ammo) if player and isElement(player) then local vip = getElementData(player, "CIFvip") or 0 if tonumber(ammo) then if (vip > 0) then if tonumber(ammo) < vip then local cash = math.ceil(tonumber(ammo)*10000 ) exports.CIFvip:removePlayerDonator(getAccountName(getPlayerAccount(player)),ammo) exports.CRPaccounts:GPM(player, cash, "converted "..ammo.." VIP Hours for "..cash) outputChatBox("You have successfully converted "..exports.CORmisc:formatNumber(ammo).." VIP hours to "..exports.CORmisc:formatNumber(cash).."", player, 0, 255, 0) else outputChatBox("You don't have VIP hours to convert!", player, 255, 0, 0) end end end end end addCommandHandler("convertviptomoney", convert)
  14. Walid

    Command

    addEventHandler("onPlayerCommand", root, function(cmd) local account = getPlayerAccount(source) if account and not isGuestAccount(account) then local accName = getAccountName (account) if cmd == "kill" then if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Soldier" ) ) then outputChatBox("Askerler İntihar etmez!! ", source, 255, 0, 0) cancelEvent() end end end end )
  15. Walid

    help

    Lol so why you deleted the code.
  16. Walid

    AccountData Help

    As far as i know double post is not allowed, anyways here is what you need. -- Server side local Blips = {} local details = {} local Entred = {} local timerTable = {} local detToSave = {} --"Vector 1 = Vehicle ID", "Vector 2 - Vector 3 - Vector 4 = X, Y, Z Coordinates", "Vector 5 = Reward Money for completing Stunt", "Vector 6 = Name of the stunt", "Vector 7 = Needed time for completing the stunt" local Markers = { {522, 1986, -1478.1, 21.5, 17500, "Test Stunt #1", 3000}, -- Marker 1 {522, 1114, -1822, 33.5, 17500, "Test Stunt #2", 1000}, -- Marker 2 {522, 776.8, -1036, 39.5, 9000, "Test Stunt #3", 1000}, -- Marker 3 {522, 1313, -1163, 41, 7500, "Test Stunt #4", 1000}, -- Marker 4 {522, 1404, -806, 85, 7500, "Test Stunt #5", 1000}, -- Marker 5 {522, 775.7, -1060.5, 33.2, 5000, "Test Stunt #6", 1000}, -- Marker 6 } function allowedVehicles( hitElement, matchingDimension ) if matchingDimension and isElement(hitElement) and getElementType(hitElement) == "player" then if isPedInVehicle ( hitElement ) then local vehicle = getPedOccupiedVehicle ( hitElement ) if vehicle then if Entred[source] then outputChatBox("Sorry you can't enter the marker twice" , hitElement,255,0,0) return end local theTable = details[source] if (theTable) then local model, cash, name, timer = details[source][1], details[source][2], details[source][3], details[source][4] if getElementModel (vehicle) == model then if timer then if not isTimer(timerTable[hitElement]) then timerTable[hitElement] = setTimer(StuntComplete,tonumber(timer),1,hitElement,source,cash,name) end else StuntComplete(hitElement,source,cash,name) end else outputChatBox ( "You have entered in Stunt with wrong vehicle", hitElement, 255, 0, 0 ) end end end end end end function StuntComplete (player,marker,cash,markerName) if isElement ( player ) then if isElementWithinMarker(player, marker) then Entred[marker] = true givePlayerMoney ( player, tonumber(cash)) outputChatBox ( "You have completed the Stunt and earned "..tonumber(cash).."$", player, 0, 255, 0 ) if isElement( Blips[marker] ) then setBlipColor ( Blips[marker], 0, 255, 0, 255 ) setMarkerColor (marker,0, 255, 0, 255 ) end local playerAccount = getPlayerAccount (player) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then local totalStunts = getAccountData ( playerAccount, "totalStunts" ) or 0 local blipColor = Vector4(getBlipColor (Blips[marker])) local markerColor = Vector4(getMarkerColor ( marker )) detToSave[marker] = {markerName,blipColor.x,blipColor.y,blipColor.z,blipColor.w,markerColor.x,markerColor.y,markerColor.z,markerColor.w} setAccountData (playerAccount, "Details",toJSON(detToSave)) setAccountData(playerAccount, "totalStunts" , tonumber(totalStunts)+1) end else outputChatBox("You failed the Stunt!", player, 255, 0, 0) end end end function leaveMar( leaveElement ) if ( isElement ( leaveElement ) and getElementType ( leaveElement ) == "player" ) then if isTimer(timerTable[leaveElement]) then outputChatBox("You failed the Stunt!", leaveElement, 255, 0, 0) killTimer(timerTable[leaveElement]) timerTable[leaveElement] = nil end end end for i , v in pairs (Markers) do HitMarker = createMarker ( v[2], v[3], v[4], "corona", 1.20, 255, 0, 0, 255 ) Blips[HitMarker] = createBlipAttachedTo( HitMarker, 0 ) details[HitMarker] = {v[1],v[5],v[6],v[7]} addEventHandler( "onMarkerHit", HitMarker, allowedVehicles ) addEventHandler ( "onMarkerLeave", HitMarker, leaveMar) end function stuntsFinished ( player ) if isElement(player) then local playerAccount = getPlayerAccount ( player ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then local count = getAccountData( playerAccount, "totalStunts" ) or 0 outputChatBox( "You have finished "..tonumber(count).."/512 Stunts", player, 0, 255, 0) end end end addCommandHandler("fstunts", stuntsFinished) function Load (_,cur,player) if not player then player = source end local Det = getAccountData(cur,"Details") if Det then for i,v in pairs(fromJSON (Det)) do local marName,rb,gb,bb,ab,rm,gm,bm,am = unpack(v) for i , mar in pairs (getElementsByType("marker")) do local theTable = details[mar] if (theTable) then local name = details[mar][3] if name == tostring(marName) then Entred[mar] = true detToSave[mar] = {marName,rb,gb,bb,ab,rm,gm,bm,am} setMarkerColor (mar,tonumber(rm),tonumber(gm),tonumber(bm),tonumber(am)) if Blips[mar] then setBlipColor (Blips[mar],rb,gb,bb,ab) end end end end end end end addEventHandler("onPlayerLogin",root,Load) function loadOnResourceStart() for i,v in pairs(getElementsByType("player")) do local account = getPlayerAccount(v) if account and not isGuestAccount(account) then Load (_,account,v) end end end addEventHandler("onResourceStart",resourceRoot,loadOnResourceStart)
  17. Walid

    AccountData Help

    i added the timer here so i'm checking if the timer exist or not. if timer then -- if yes setTimer(StuntComplete,tonumber(timer),1,hitElement,source,cash,name) else StuntComplete(hitElement,source,cash,name) end
  18. Walid

    help

    Very simple if tonumber (ammo) > tonumber (vip) then return end You create all of this and you don't know how to prevent players from converting more than they have.
  19. Walid

    AccountData Help

    1) It's very easy to do it just added the timer you want inside the table like this: {522, 1986, -1478.1, 21.5, 17.500, "Test Stunt #1",Timer here}, -- Marker 1 2) Added the timer to details table details[HitMarker] = {v[1],v[5],v[6],v[7]} 3) Then just check fi there is a timer when the player hits the marker : local model, cash, name, timer = details[source][1], details[source][2], details[source][3], details[source][4] if timer then -- setTimer here else StuntComplete(hitElement,source,cash,name) end 4) Also you need to check if the player still inside the marker with "isElementWithinMarker()" .
  20. Walid

    AccountData Help

    Working fine for me , already tested it.
  21. Walid

    AccountData Help

    You are welcome anytime. That's wrong as i can see you are just using "onMarkerLeave" event handler, there is no timer to check if the player stays inside the marker (3 sec). Anyways try to edit your code all what you need is : isElementWithinMarker() -- after 3 second check if the player still inside the marker
  22. Walid

    MTA on Mac

    check this: How to play MTA on a Mac (OSX)
  23. Walid

    AccountData Help

    Fixed many things for you and your code is working fine now. local Blips = {} local details = {} local Entred = {} local Markers = { {522, 1986, -1478.1, 21.5, 17.500, "Test Stunt #1"}, -- Marker 1 {522, 1114, -1822, 33.5, 17.500,"Test Stunt #2"}, -- Marker 2 {522, 776.8, -1036, 39.5, 9000,"Stunt Name Here"}, -- Marker 3 {522, 1313, -1163, 41, 7500,"Stunt Name Here"}, -- Marker 4 {522, 1404, -806, 85, 7500,"Stunt Name Here"}, -- Marker 5 {522, 775.7, -1060.5, 33.2, 5000,"Stunt Name Here"}, -- Marker 6 } function allowedVehicles( hitElement, matchingDimension ) if matchingDimension and isElement(hitElement) and getElementType(hitElement) == "player" then if isPedInVehicle ( hitElement ) then local vehicle = getPedOccupiedVehicle ( hitElement ) if vehicle then if Entred[hitElement] == source then outputChatBox("Sorry you can't enter the marker twice" , hitElement,255,0,0) return end local theTable = details[source] if (theTable) then local model, cash, name = details[source][1], details[source][2], details[source][3] if getElementModel ( vehicle ) == model then StuntComplete(hitElement,source,cash,name) -- You don't need a timer here Entred[hitElement] = source else outputChatBox ( "You have entered in Stunt with wrong vehicle", hitElement, 255, 0, 0 ) end end end end end end function StuntComplete (player,marker,cash,markerName) if isElement ( player ) then givePlayerMoney ( player, tonumber(cash)) outputChatBox ( "You have completed the Stunt and earned "..tonumber(cash).."$", player, 0, 255, 0 ) if isElement( Blips[marker] ) then setBlipColor ( Blips[marker], 0, 255, 0, 255 ) setMarkerColor (marker,0, 255, 0, 255 ) outputDebugString("done") end local playerAccount = getPlayerAccount (player) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then local totalStunts = getAccountData ( playerAccount, "totalStunts" ) or 0 local name = markerName local rb,gb,bb,ab = getBlipColor (Blips[marker]) local rm,gm,bm,am = getMarkerColor ( marker ) local Det = toJSON({name,rb,gb,bb,ab,rm,gm,bm,am}) setElementData (player, "entered.marker", true ) setAccountData (playerAccount, "Details", Det ) setAccountData(playerAccount, "totalStunts" , tonumber(totalStunts)+1) end end end -- I don't know why you need it ??? function leaveMar( leaveElement ) if ( isElement ( leaveElement ) and getElementType ( leaveElement ) == "player" ) then setElementData ( leaveElement, "entered.marker", false ) outputChatBox("You failed the Stunt!", leaveElement, 255, 0, 0) end end for i , v in pairs (Markers) do HitMarker = createMarker ( v[2], v[3], v[4], "corona", 1.20, 255, 0, 0, 255 ) Blips[HitMarker] = createBlipAttachedTo( HitMarker, 0 ) details[HitMarker] = {v[1],v[5],v[6]} addEventHandler( "onMarkerHit", HitMarker, allowedVehicles ) addEventHandler ( "onMarkerLeave", HitMarker, leaveMar) end function stuntsFinished ( player ) if isElement(player) then local playerAccount = getPlayerAccount ( player ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then local count = getAccountData( playerAccount, "totalStunts" ) or 0 outputChatBox( "You have finished "..tonumber(count).."/512 Stunts", player, 0, 255, 0) end end end addCommandHandler("fstunts", stuntsFinished) function Load (_,cur) local Det = getAccountData(cur,"Details") if Det then local marName,rb,gb,bb,ab,rm,gm,bm,am = unpack(fromJSON(Det)) for i , mar in pairs (getElementsByType("marker")) do local theTable = details[mar] if (theTable) then local name = details[mar][3] if name == tostring(marName) then Entred[source] = mar setMarkerColor (mar,tonumber(rm),tonumber(gm),tonumber(bm),tonumber(am)) end end end end end addEventHandler("onPlayerLogin",root,Load)
×
×
  • Create New...