Jump to content

roaddog

Members
  • Posts

    346
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by roaddog

  1. Option 1: Change this line local username = getAccountName(getPlayerAccount(playerSource)) to local username = getPlayerAccount(playerSource) Option 2: or add getAccountName(owner) at the if clause line 7. choose either of them.
  2. Well that means the "owner" data is not set to the account. Add this line after the getAccountName line to check whether the owner was accountname outputChatBox(tostring(owner).. " == ".. tostring(username) .." ?") post the result here. Did it pass the messages in chatbox? I have tested this, and this was actually worked.
  3. Replace the last function lines with this. addEventHandler("onVehicleExplode",vehicle, function () setTimer ( function ( vehicleID, vehicle ) if ( vehicleID and type ( vehicleID ) == "number" ) then table.remove(vehicles, vehicleID) if isElement( vehicle ) then destroyElement ( vehicle ) end executeSQLQuery("CREATE TABLE IF NOT EXISTS newprivatevehicles (Model NUMERIC, X NUMBERIC, Y NUMERIC, Z NUMERIC, RX NUMERIC, RY NUMERIC, RZ NUMERIC, LOCK TEXT, GROUPLOCK TEXT, Color TEXT)") createPrivateVehicle(model, x, y, z, rot, color, upgrades, dataType, allowedTo) end end ,10000, 1, #vehicles, source ) return vehicle end )
  4. --[[ +---------------------------------------------------------------------------- | =================== Script made by Jasper~ =================== | | Please, respect my work -> do not remove the copyrights. | This script took me 45 minutes of my wonderfull life | Bugs/Suggestions? Add me on skype! +----------------------------------------------------------------------------- ]]-- function lock_newvehicles(player, seat, jacked) if isPedOnGround(player) == true then if getElementData(source, "whoLocked") == "team" then local lock = getElementData(source, "lockedTo") if seat == 0 then if getTeamName(getPlayerTeam(player)) == lock then return true else cancelEvent()exports.DZcommands:sendClientMessage("This vehicle is locked for the following team(s): "..lock..".", player, 255, 255, 255) end end elseif getElementData(source, "whoLocked") == "class" then local lock = getElementData(source, "lockedTo") if seat == 0 then if getElementData(player, "class") == lock then return true else cancelEvent() exports.DZcommands:sendClientMessage("This vehicle is locked for the following class(es): "..lock..".", player, 255, 255, 255) end end elseif getElementData(source, "whoLocked") == "account" then local lock = getElementData(source, "lockedTo") local accName = getAccountName(getPlayerAccount(player)) if seat == 0 then if accName == lock then return true else cancelEvent() exports.DZcommands:sendClientMessage("This vehicle is locked and belongs to the following user(s): "..lock..".", player, 255, 255, 255) end end elseif getElementData(source, "whoLocked") == "acl" then local lock = getElementData(source, "lockedTo") local accName = getAccountName(getPlayerAccount(player)) if seat == 0 then if isObjectInACLGroup("user."..accName, aclGetGroup(lock)) then return true else cancelEvent() exports.DZcommands:sendClientMessage("This vehicle is locked for the following group(s): "..lock..".", player, 255, 255, 255) end end end end end addEventHandler("onVehicleStartEnter", getRootElement(), lock_newvehicles) function add_new_vehicle (source, command, whoLock, ...) local accName = getAccountName(getPlayerAccount(source)) if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then if isPedInVehicle(source) == true then if not isPedDead(source) == true then local newlock = whoLock if newlock == "team" or newlock == "class" or newlock == "acl" or newlock == "account" then if #arg > 0 then local occupiedVeh = getPedOccupiedVehicle(source) local model = getElementModel(occupiedVeh) local x,y,z = getElementPosition(occupiedVeh) local rx,ry,rz = getElementRotation(occupiedVeh) local lock = table.concat(arg, " ") local groupLock = whoLock local r1, g1, b1, r2, g2, b2 = getVehicleColor(occupiedVeh, true) local color = tostring(r1.. "," ..g1.. "," ..b1.. "," ..r2.. "," ..g2.. "," ..b2) local addVeh = executeSQLQuery("INSERT INTO newprivatevehicles (Model,X,Y,Z,RX,RY,RZ,LOCK,GROUPLOCK,Color) VALUES(?,?,?,?,?,?,?,?,?,?)", tonumber(model), tonumber(x), tonumber(y), tonumber(z), tonumber(rx), tonumber(ry), tonumber(rz), lock, groupLock, tostring(color)) exports.DZcommands:sendClientMessage("Vehicle successfuly created, info: "..groupLock.." - "..lock..".", source, 0,255,0) local newVehicle = createVehicle (tonumber(model),tonumber(x),tonumber(y),tonumber(z), tonumber(rx), tonumber(ry), tonumber(rz)) setElementData(newVehicle, "lockedTo", lock) setElementData(newVehicle, "whoLocked", whoLock) setVehicleColor (newVehicle, tonumber(r1), tonumber(g1), tonumber(b1), tonumber(r2), tonumber(g2), tonumber(b2)) warpPedIntoVehicle(source, newVehicle) else exports.DZcommands:sendClientMessage("Wrong command usage, try '/addveh '.", source, 255, 255, 255) end else exports.DZcommands:sendClientMessage("Wrong command usage, try '/addveh '.", source, 255, 255, 255) end exports.DZcommands:sendClientMessage("You are dead, respawn to make this vehicle!", source, 255, 255, 255) end elseexports.DZcommands:sendClientMessage("You are not in a vehicle, go in a vehicle to create one!", source, 255, 255, 255) end end end addCommandHandler("addveh", add_new_vehicle) -- remove function function remove_lockedvehicle (source) local accName = getAccountName(getPlayerAccount(source)) if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then local vehicle = getPedOccupiedVehicle(source) local lock = getElementData(vehicle, "lockedTo") if isPedInVehicle(source) == true then if getElementData(vehicle, "lockedTo") ~= "" then executeSQLQuery("DELETE FROM newprivatevehicles WHERE LOCK=?", lock) destroyElement(vehicle) exports.DZcommands:sendClientMessage("Vehicle has successfully been removed from the database.", source, 255, 255, 255) else exports.DZcommands:sendClientMessage("* This is not a private vehicle, take another vehicle!", source, 255, 255, 255) end else exports.DZcommands:sendClientMessage("* You must be in a vehicle in order to remove this vehicle.", source, 255, 255, 255) end end end addCommandHandler("remveh", remove_lockedvehicle) addEventHandler("onVehicleExplode",vehicle, function () setTimer ( function ( vehicleID, vehicle ) if ( vehicleID and type ( vehicleID ) == "number" ) then table.remove(vehicles, vehicleID) if isElement( vehicle ) then destroyElement ( vehicle ) end table_lockedvehicles() createPrivateVehicle(model, x, y, z, rot, color, upgrades, dataType, allowedTo) end end ,10000, 1, #vehicles, source ) return vehicle end) function table_lockedvehicles () executeSQLQuery("CREATE TABLE IF NOT EXISTS newprivatevehicles (Model NUMERIC, X NUMBERIC, Y NUMERIC, Z NUMERIC, RX NUMERIC, RY NUMERIC, RZ NUMERIC, LOCK TEXT, GROUPLOCK TEXT, Color TEXT)") end
  5. Should work now, if the "owner" is account name. function lockCar(playerSource, command) if not isPedInVehicle(playerSource) then return end local carID = getPedOccupiedVehicle(playerSource) local owner = getElementData(carID, "owner") local username = getAccountName(getPlayerAccount(playerSource)) if owner == username then if (isVehicleLocked(carID)) then local unlocked = setVehicleLocked(carID, false) if (unlocked) then outputChatBox("#7D7D7DCAR MANAGER: #DEDEDEYour " .. getVehicleName(carID) .. " has been successfully unlocked!", playerSource, 255, 255, 255, true) else outputChatBox("#7D7D7DCAR MANAGER: #DEDEDEYour " .. getVehicleName(carID) .. " was not unlocked successfully!", playerSource, 255, 255, 255, true) end else local locked = setVehicleLocked(carID, true) if (locked) then outputChatBox("#7D7D7DCAR MANAGER: #DEDEDEYour " .. getVehicleName(carID) .. " has been successfully locked!", playerSource, 255, 255, 255, true) else outputChatBox("#7D7D7DCAR MANAGER: #DEDEDEYour " .. getVehicleName(carID) .. " was not locked successfully!", playerSource, 255, 255, 255, true) end end else outputChatBox("#7D7D7DCAR MANAGER: #DEDEDEThis is not your vehicle!", playerSource, 255, 255, 255, true) end end addCommandHandler("lock", lockCar) function unlockOnExit(vehicle, seat, jacked) if (seat ~= 0) then return end if (isElement(source)) and (isVehicleLocked(vehicle)) then setVehicleLocked(vehicle, false) outputChatBox("#7D7D7DCAR MANAGER: #DEDEDEYour " .. getVehicleName(vehicle) .. " has been successfully unlocked!", source, 255, 255, 255, true) end end addEventHandler("onPlayerVehicleExit", getRootElement(), unlockOnExit)
  6. --[[ gates = { { pos={ x, y, z}, rot={x, y, z}, model=980, world={ int, dim}, size=2, res={ team={""}, job={""}}, move={x, y, z}, animation={enter, leave}, settings={ vehicle=boolean}}, } --]]
  7. function lockCar(playerSource, command) local carID = getPedOccupiedVehicle(playerSource) if (carID) and (isVehicleLocked(carID)) and (getVehicleOccupant(carID) == playerSource) then local owner = getElementData(carID, "owner") if owner == getPlayerName(playerSource) then local username = getAccountName(getPlayerAccount(playerSource)) if username then local unlocked = setVehicleLocked(carID, false) if (unlocked) then outputChatBox("#7D7D7DCAR MANAGER: #DEDEDEYour " .. getVehicleName(carID) .. " has been successfully unlocked!", playerSource, 255, 255, 255, true) else outputChatBox("#7D7D7DCAR MANAGER: #DEDEDEYour " .. getVehicleName(carID) .. " was not unlocked successfully!", playerSource, 255, 255, 255, true) end end end else local owner = getElementData(carID, "owner") if owner == getPlayerName(playerSource) then local username = getAccountName(getPlayerAccount(playerSource)) if username then local locked = setVehicleLocked(carID, true) if (locked) then outputChatBox("#7D7D7DCAR MANAGER: #DEDEDEYour " .. getVehicleName(carID) .. " has been successfully locked!", playerSource, 255, 255, 255, true) else outputChatBox("#7D7D7DCAR MANAGER: #DEDEDEYour " .. getVehicleName(carID) .. " was not locked successfully!", playerSource, 255, 255, 255, true) end end end end addCommandHandler("lock", lockCar) function unlockOnExit(thePlayer, seat, jacker) if (seat == 0) and (thePlayer) and (isVehicleLocked(source)) then local unlocked = setVehicleLocked(source, false) if (unlocked) then outputChatBox("#7D7D7DCAR MANAGER: #DEDEDEYour " .. getVehicleName(source) .. " has been successfully unlocked!", thePlayer, 255, 255, 255, true) end end end addEventHandler("onVehicleExit", getRootElement(), unlockOnExit) Try this, May I know how did you store the "owner" data? is it stored with their account or player name?
  8. function lockCar(playerSource, command) local carID = getPedOccupiedVehicle(playerSource) if (carID) and (isVehicleLocked(carID)) and (getVehicleOccupant(carID) == playerSource) then local owner = getElementData(carID, "owner") if owner and owner == playerSource then local username = getAccountName(getPlayerAccount(player)) if username then local unlocked = setVehicleLocked(carID, false) if (unlocked) then outputChatBox("#7D7D7DCAR MANAGER: #DEDEDEYour " .. getVehicleName(carID) .. " has been successfully unlocked!", playerSource, 255, 255, 255, true) else outputChatBox("#7D7D7DCAR MANAGER: #DEDEDEYour " .. getVehicleName(carID) .. " was not unlocked successfully!", playerSource, 255, 255, 255, true) end end end else local owner = getElementData(carID, "owner") if owner and owner == playerSource then local username = getAccountName(getPlayerAccount(player)) if username then local locked = setVehicleLocked(carID, true) if (locked) then outputChatBox("#7D7D7DCAR MANAGER: #DEDEDEYour " .. getVehicleName(carID) .. " has been successfully locked!", playerSource, 255, 255, 255, true) else outputChatBox("#7D7D7DCAR MANAGER: #DEDEDEYour " .. getVehicleName(carID) .. " was not locked successfully!", playerSource, 255, 255, 255, true) end end end end addCommandHandler("lock", lockCar) function unlockOnExit(thePlayer, seat, jacker) if (seat == 0) and (thePlayer) and (isVehicleLocked(source)) then local unlocked = setVehicleLocked(source, false) if (unlocked) then outputChatBox("#7D7D7DCAR MANAGER: #DEDEDEYour " .. getVehicleName(source) .. " has been successfully unlocked!", thePlayer, 255, 255, 255, true) end end end addEventHandler("onVehicleExit", getRootElement(), unlockOnExit)
  9. Try this. triggerClientEvent(source,"openteams.getPlayerPermissionLevel.serverGave", source, playerRank) first parameter "source" is an optional (sentTo) parameter for triggerClientEvent: sendTo: The event will be sent to all players that are children of the specified element. By default this is the root element, and hence the event is sent to all players. If you specify a single player it will just be sent to that player. This argument can also be a table of player elements.
  10. roaddog

    math problem

    It worked, Thanks IYAMA!
  11. roaddog

    math problem

    results = {} function divideThisValue(value) local value = value local splitUpInParts = 5 ------ local valuePeaks = (100/splitUpInParts)/100 local results = {} local valueInParts = math.floor((value/splitUpInParts)+0.5) local valueTotal = 0 for i=1,splitUpInParts-1 do local peak if math.random(2) == 1 then peak = math.random(math.floor((valueInParts*valuePeaks)+0.5)) else peak = -math.random(math.floor((valueInParts*valuePeaks)+0.5)) end local result = valueInParts+ peak results[#results+1] = result valueTotal = valueTotal+result end results[#results+1] = value - valueTotal end addEvent("onEstimatingOver", true) addEventHandler("onEstimatingOver", root, function() onFactoryWindowClose() if estimating then estimating = false end valueof = getElementData(getLocalPlayer(), "Rocks:iron") or 0 if guiGetVisible(GUIEditors.window[1]) then divideThisValue(valueof) copper = results[1] bronze = results[2] silver = results[3] iron = results[4] gold = results[5] guiSetText(GUIEditors.copper, tostring(copper).." grams\n"..tonumber(copper*25).."$") guiSetText(GUIEditors.bronze, tostring(broze).." grams\n"..tonumber(bronze*35).." $") guiSetText(GUIEditors.silver, tostring(silver).." grams\n"..tonumber(silver*45).." $") guiSetText(GUIEditors.iron, tostring(iron).." grams\n"..tonumber(iron*46).." $") guiSetText(GUIEditors.gold, tostring(gold).." grams\n"..tonumber(gold*60).." $") end end) I failed, what's wrong? these vars get nil value.
  12. roaddog

    math problem

    So guys, Im stuck at this. I want to divide a random number by 5. value = math.random(100, 500) how to do so? each divider also has random number, and when we sum them up result is the value. for example value is 500, we divide it by 5 get random number 100, 210, 140, 50. I want to operate this but I dont know how to do to get these 5 random values. Thanks.
  13. You can define the blip using variable and then check if it exists, destroyElement() local hasBeenCollected=true local theDrug local locx,locy,locz,hint={-2923.1591, -1126.8721}, {1165.1446, 834.1354}, {13.5312, 3.0777}, {"The back yards of san fiero", "A oceanic rock next to a bridge support"} --An array with drug package locations and hints function pickedUpDrug(pickup,dimension) -- Called when something is picked up. if(getElementData(pickup, "rpg.drug") == "a") then local earnings=math.random(2000)--Generate random earnings from 1 to 2000 local money = getPlayerMoney(source) setPlayerMoney(source , money + earnings)--Give player money does nothing where as this seems to work fine. hasBeenCollected = true --Tell setupDrugRun we've collected it destroyElement( pickup )--Make sure we destroy our pickup if isElement(drugBlip) then --Check if it exists destroyElement(drugBlip)-- we destroy our "drugBlip" end outputChatBox ( getPlayerName(source).." has collected the drug package for $"..earnings, getRootElement(), 0, 0, 255, true )--Tell everyone about it elseif(getElementData(pickup, "rpg.money") == "mons") then --This can be ignored it has nothing to do with the drug run local money = getPlayerMoney(source) setPlayerMoney(source , money + 100) destroyElement(pickup) end end function setupDrugRun() if(hasBeenCollected == true) then --Has our drug package been collected hasBeenCollected=false --If so reset it local location=math.random(2) --Choose a random location from the array theDrug = createPickup ( locx[location], locy[location], locz[location], 3, 1279) --Possibly not passing the element to theDrug drugBlip = createBlipAttachedTo ( theDrug, 36) -- Define the blip setElementData(theDrug, "rpg.drug", "a")--We cannot pass theDrug to addEventHandler as element(Perhaps a bug or user error) outputChatBox ( "A new drug package is available for pick up", getRootElement(), 0, 0, 255, true )--Tell everyone about it. end end function startDrugRun() --Sets up the timer for the drug run this can be ignored setTimer(setupDrugRun, 1000, 0) end
  14. I have tested and it's worked, make sure you dont have a rights to kick player or make ur self as everyone or something. otherwise you will not see it.
  15. function onEnter (vehicle, seat, jacker) if ( getElementModel(vehicle) == 432 ) then if ( not hasObjectPermissionTo(source, "function.kickPlayer")) then killPed(source) outputChatBox("NO RHINO", source, 255, 0, 0 ) destroyElement(vehicle) end end end addEventHandler("onPlayerVehicleEnter", getRootElement(), onEnter ) function onSwitchToMinigun (previous, current) if ( current == 38 ) then if ( not hasObjectPermissionTo(source, "function.kickPlayer")) then killPed(source) outputChatBox("NO MINIGUN", source, 255, 0, 0 ) end end end addEventHandler("onPlayerWeaponSwitch", getRootElement(), onSwitchToMinigun ) Try this, instead of using else, you could just add "not" logical paramenter at if statement.
  16. Thank you again TAPL.
  17. roaddog

    [HELP] Script

    function shoutAdmin(thePlayer, cmd, ...) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) -- get his account name if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then -- Does he have access to Admin functions? local msg = table.concat({...}, " ") outputChatBox("Admin"..getPlayerName(thePlayer):gsub("#%x%x%x%x%x%x","")..": "..msg, root, 255, 0, 0) else outputChatBox ( "TesT", thePlayer, 255, 255, 255, true ) end end addCommandHandler("ann", shoutAdmin) I guess this is what you're trying to do.
  18. Hey, how to detect/get element(blip) that is attached to other element(object)? I used createBlipAttachedTo to create the blip, and local attached = getElementAttachedTo ( tree ) if ( attached ) then outputChatBox ( "This tree is attached to a " .. getElementType(attached) ) else outputChatBox( "This tree is not attached to an element") end the attached var gives a false result.
  19. Thanks, It works o/
  20. the element is an object. I found this https://wiki.multitheftauto.com/wiki/On ... jectDamage, and I got an error says source is nil? eventho the element was created. function outputLoss(loss) if not isElement(source) then return end if getElementModel(source) ~= 897 then return end local oldHealth = getElementHealth(source) local hitX, hitY, hitZ = getElementPosition(source) setTimer(function() local newHealth = getElementHealth(source) outputChatBox("Real loss: "..(newHealth-oldHealth)) outputChatBox("Theoretical loss: "..loss) if getElementHealth(source) == 0 then destroyElement(source) createExplosion(hitX, hitY, hitZ, 8, true, -1.0, false) end end,100,1) end addEventHandler("onClientObjectDamage", root, outputLoss)
  21. No, I mean, The source of this event is the element that got damaged.
  22. Due to this https://wiki.multitheftauto.com/wiki/On ... WeaponFire event does not work on melee weapon. How can I make a simple function that does the trick for it? I want to detect a player who hits an element using shovel weapon. Thanks.
  23. roaddog

    Train

    Yes there's! This script made by Mrbrutus. It spawns trains with trailers on a railroad. Check it out: https://github.com/GTWCode/GTW-RPG/tree ... s/GTWtrain PS: I like trains ._.
  24. Ah, after reading over and over again, I have understood now. Thanks for helping me out.
  25. As the title said, how to calculate the world coordinates of the behind of vehicle? Like this: I tried the getVehicleComponentPosition but getting confused because of this vehicle component
×
×
  • Create New...