Jump to content

Dazee

Members
  • Posts

    39
  • Joined

  • Last visited

Everything posted by Dazee

  1. Thanks for noticing that will fix it when i get time then post here EDIT:I fixed it decided to use account data function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function markPlayer(thePlayer,commandname,player2) playername = getPlayerFromPartialName(player2) if player2 == nil or not playername then outputChatBox("You have to insert a valid player name to mark them, or a part of their name!",thePlayer,255,0,0) cancelEvent() else playername = getPlayerFromPartialName(player2) playername2 = getPlayerName(playername) playeraccount2 = getPlayerAccount(thePlayer) if getAccountData(playeraccount2, "settings.marking") == false then if getAccountData(playeraccount2, "marked.latest.temp") == playername2 then cancelEvent() outputChatBox("" ..playername2.. " is already marked use /unmark to remove the mark!",thePlayer, 255,0,0) else outputChatBox("" ..playername2.. " has been marked!",thePlayer,0,255,0) blip1 = createBlipAttachedTo(playername,58) setElementVisibleTo(blip1, root, false) setElementVisibleTo(blip1, thePlayer, true) --setElementData(thePlayer, "tempdata.marked1",true) setAccountData(playeraccount2, "marked.latest.temp", playername2 ) end else outputChatBox("" ..playername2.. " has disabled marking!",thePlayer, 255,0,0) end end end function checkMark(thePlayer,commandname,player3) playername = getPlayerFromPartialName(player3) playername4 = getPlayerName(playername) playeraccount3 = getPlayerAccount(thePlayer) if player3 == nil or not playername then outputChatBox("You have to insert a player's name to unmark them, or a part of their name!",thePlayer,255,0,0) cancelEvent() else if getAccountData(playeraccount3, "marked.latest.temp") == playername2 then outputChatBox("The mark was removed from "..playername2.. "",thePlayer,255,0,0) destroyElement(blip1) setAccountData(playeraccount3,"marked.latest.temp",false) elseif getAccountData(playeraccount3, "marked.latest.temp") == false then outputChatBox("" ..playername4.. " is not marked!",thePlayer,255,0,0) cancelEvent() end end end function disableMarking(thePlayer,commandname,atr3) playeraccount = getPlayerAccount(thePlayer) if atr3 == nil or not "marking" then outputChatBox("You have to insert a setting to see the list of settings do /settings list",thePlayer,0,255,0) cancelEvent() elseif atr3 == "marking" then if getAccountData(playeraccount, "settings.marking") == true then outputChatBox("You have enabled marking!",thePlayer, 0,255,0) setAccountData(playeraccount, "settings.marking", false) elseif getAccountData(playeraccount, "settings.marking") == false then outputChatBox("You have disabled marking!",thePlayer, 255,0,0) setAccountData(playeraccount, "settings.marking", true) end elseif atr3 == "sms" then if getAccountData(playeraccount, "settings.sms") == true then outputChatBox("Your SMS is enabled now, others may SMS you!",thePlayer,0,255,0) setAccountData(playeraccount, "settings.sms",false) elseif getAccountData(playeraccount, "settings.sms") == false then outputChatBox("You have disabled your SMS, no one can SMS you now!",thePlayer,255,0,0) setAccountData(playeraccount, "settings.sms", true) end end end addCommandHandler("mark",markPlayer) addCommandHandler("unmark",checkMark) addCommandHandler("settings",disableMarking) Altho i forgot to fix the sms attribute part just lazy bout it bcuz im not using the attribute for anything yet
  2. Finished my script was no need to use client side it didn't want to work for some reason createBlipAttachedTo not sure why maybe MTA is bugged or something but suceeded to make it only visible to the player that actually marked someone and also made a lot of improvements on my script and soon adding an SMS feature , setElementVisibleTo FTW function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function markPlayer(thePlayer,commandname,player2) playername = getPlayerFromPartialName(player2) if player2 == nil or not playername then outputChatBox("You have to insert a valid player name to mark them, or a part of their name!",thePlayer,255,0,0) cancelEvent() else playername = getPlayerFromPartialName(player2) playername2 = getPlayerName(playername) playeraccount2 = getPlayerAccount(playername) if getAccountData(playeraccount2, "settings.marking") == false then if getElementData(playername, "tempdata.marked") == true then cancelEvent() outputChatBox("" ..playername2.. " is already marked use /unmark to remove the mark!",thePlayer, 255,0,0) else outputChatBox("" ..playername2.. " has been marked!",thePlayer,0,255,0) blip1 = createBlipAttachedTo(playername,58) setElementVisibleTo(blip1, root, false) setElementVisibleTo(blip1, thePlayer, true) setElementData(playername, "tempdata.marked",true) end else outputChatBox("" ..playername2.. " has disabled marking!",thePlayer, 255,0,0) end end end function checkMark(thePlayer,commandname,player3) playername = getPlayerFromPartialName(player3) playername4 = getPlayerName(playername) if player3 == nil or not playername then outputChatBox("You have to insert a player's name to unmark them, or a part of their name!",thePlayer,255,0,0) cancelEvent() else if getElementData(playername, "tempdata.marked") == true then outputChatBox("The mark was removed from "..playername2.. "",thePlayer,255,0,0) destroyElement(blip1) setElementData(playername,"tempdata.marked", false) elseif getElementData(playername, "tempdata.marked") == false then outputChatBox("" ..playername4.. " is not marked!",thePlayer,255,0,0) cancelEvent() end end end function disableMarking(thePlayer,commandname,atr3) playeraccount = getPlayerAccount(thePlayer) if atr3 == nil or not attribute then outputChatBox("You have to insert a setting to see the list of settings do /settings list",thePlayer,0,255,0) cancelEvent() elseif atr3 == "marking" then if getAccountData(playeraccount, "settings.marking") == true then outputChatBox("You have enabled marking!",thePlayer, 0,255,0) setAccountData(playeraccount, "settings.marking", false) elseif getAccountData(playeraccount, "settings.marking") == false then outputChatBox("You have disabled marking!",thePlayer, 255,0,0) setAccountData(playeraccount, "settings.marking", true) end elseif atr3 == "sms" then if getAccountData(playeraccount, "settings.sms") == true then outputChatBox("Your SMS is enabled now, others may SMS you!",thePlayer,0,255,0) setAccountData(playeraccount, "settings.sms",false) elseif getAccountData(playeraccount, "settings.sms") == false then outputChatBox("You have disabled your SMS, no one can SMS you now!",thePlayer,255,0,0) setAccountData(playeraccount, "settings.sms", true) end end end addCommandHandler("mark",markPlayer) addCommandHandler("unmark",checkMark) addCommandHandler("settings",disableMarking)
  3. Tried making it clientside it just wouldnt work (im noob at this and still learning ) could you make it clientside i would appreciate it
  4. So I want the blip to be visible only to the player who created it I am not sure what to do here is my script below! function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function markPlayer(thePlayer,commandname,player2) playername = getPlayerFromPartialName(player2) playername2 = getPlayerName(playername) playeraccount2 = getPlayerAccount(playername) allplayers = getElementsByType("player") if getAccountData(playeraccount2, "settings.marking") == false then if getElementData(playername, "tempdata.marked") == true then cancelEvent() outputChatBox("That player is already marked use /unmark to remove the mark!",thePlayer, 255,0,0) else outputChatBox("" ..playername2.. " has been marked!",thePlayer,0,255,0) blip1 = createBlipAttachedTo(playername,58) setElementVisibleTo(blip1, allplayers, false) setElementVisibleTo(blip1, thePlayer, true) end setElementData(playername, "tempdata.marked",true) end else outputChatBox("" ..playername2.. " has disabled marking!",thePlayer, 255,0,0) end end function checkMark(thePlayer,commandname,player3) playername = getPlayerFromPartialName(player3) if getElementData(playername, "tempdata.marked") == true then outputChatBox("The mark was removed from "..playername2.. "",thePlayer,255,0,0) destroyElement(blip1) setElementData(playername,"tempdata.marked", false) end end function disableMarking(thePlayer,commandname,atr3) playeraccount = getPlayerAccount(thePlayer) if atr3 == "marking" then if getAccountData(playeraccount, "settings.marking") == true then outputChatBox("You have enabled marking!",thePlayer, 0,255,0) setAccountData(playeraccount, "settings.marking", false) elseif getAccountData(playeraccount, "settings.marking") == false then outputChatBox("You have disabled marking!",thePlayer, 255,0,0) setAccountData(playeraccount, "settings.marking", true) end else outputChatBox("That setting does not exist!",thePlayer,255,0,0) end end addCommandHandler("mark",markPlayer) addCommandHandler("unmark",checkMark) addCommandHandler("settings",disableMarking)
  5. Okay so i have created this script but i want it to every time i make a delivery it adds +1 value to the previous value in the column of the smuggles how can i do that ? here's the fulll code. databaseConnection = dbConnect("sqlite", "file.db") function createTeamCriminalOnStart() criminalTeam = createTeam("Criminal", 255,255,255) end function isPlayerInTeam(player, team) assert(isElement(player) and getElementType(player) == "player", "Bad argument 1 @ isPlayerInTeam [player expected, got " .. tostring(player) .. "]") assert((not team) or type(team) == "string" or (isElement(team) and getElementType(team) == "team"), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got " .. tostring(team) .. "]") return getPlayerTeam(player) == (type(team) == "string" and getTeamFromName(team) or (type(team) == "userdata" and team or (getPlayerTeam(player) or true))) end function smuggleStart(player) if isPlayerInTeam(player, "Criminal") then northRockHut = createMarker(-706.5,954.0999,11.3999, "cylinder", 2.0, 175,0,255,150) outputChatBox("You need to deliver the smuggled goods to North Rock Hut!",player) else outputChatBox("You are not a criminal!",player) end end function ifDelivered(thePlayer, matchingDimension) local randomAmmount = math.random(250,5000) local addOne = 1 if isElementWithinMarker(thePlayer, northRockHut) then destroyElement(northRockHut) executeSQLQuery("CREATE TABLE IF NOT EXISTS players (smuggles TEXT, smuggles2 TEXT, name TEXT)") executeSQLQuery("CREATE TABLE IF NOT EXISTS `players` (`smuggles` TEXT, `smuggles2` TEXT, `name` TEXT)") givePlayerMoney(thePlayer,randomAmmount) outputChatBox("You have delivered the goods and earned:",thePlayer ) executeSQLQuery("ALTER TABLE players ADD IF NOT EXISTS smuggles;") executeSQLQuery("INSERT INTO players('smuggles') VALUES(?)",tonumber(1) ) else outputChatBox("You are not at the marker!!!", thePlayer) end end function becomeCriminal(thePlayer) setPlayerTeam(thePlayer, criminalTeam) outputChatBox("You are now a criminal!") end function checkSmuggles(thePlayer) local getHisSmuggles = executeSQLQuery("SELECT smuggles FROM players WHERE name=?",playerName) if(#getHisSmuggles == 0) then outputChatBox("You haven't smuggled at all",thePlayer) else outputChatBox("You have smuggled: " ..result[1].smuggles, thePlayer) end end addEventHandler("onResourceStart", resourceRoot, createTeamCriminalOnStart) addCommandHandler("smuggle", smuggleStart) addCommandHandler("criminal", becomeCriminal) addCommandHandler("deliver", ifDelivered) addCommandHandler("smuggles", checkSmuggles)
  6. You just broke the script btw I figured it out on my own thanks for trying
  7. Ok so I created a script for teams criminals,civilians I made it so civilians can't aim or shoot, and made it so criminals can aim and shoot but when i call an eventhandler that checks restrictions for criminals that enables them to shoot and I do that while I am in a civilian team I get allowed to shoot, so I was wondering if I could cancelEvent() only for a certain team and how. BTW here is my script function createTeamsOnStart () civilTeam = createTeam ( "Civilians", 0, 153, 0 ) criminalTeam = createTeam ( "Criminals", 255, 0, 0 ) end addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart ) function becomeCivil ( thePlayer ) setPlayerTeam ( thePlayer, civilTeam ) outputChatBox ("You are now a Civilian!",thePlayer,0, 153, 0 ) if ( civilTeam ) then toggleControl (thePlayer, "fire", false ) toggleControl (thePlayer, "aim_weapon", false ) else toggleControl (thePlayer, "fire", true ) toggleControl (thePlayer, "aim_weapon", true ) end end end function becomeCriminal ( thePlayer ) setPlayerTeam ( thePlayer, criminalTeam ) outputChatBox ("You are now a Criminal!", thePlayer, 255, 0, 0 ) if ( getTeamFriendlyFire ( criminalTeam ) == false ) then setTeamFriendlyFire (criminalTeam, true) end end function checkRestrictions( ) if (criminalTeam) then toggleControl ( source, "fire", true ) toggleControl ( source, "aim_weapon", true ) end end addEventHandler ( "onPlayerWeaponSwitch", getRootElement (), checkRestrictions ) addCommandHandler( "criminal", becomeCriminal ) addCommandHandler( "quitjob", becomeCivil )
  8. It creates the blip correctly and everything, but when I try to remove the blip it displays the text saying that "The blip has been removed" but the blip still stays on the radar.
  9. Ok i have come up with this function createPartyBlip ( thePlayer, commandName ) local x,y,z = getElementPosition (thePlayer) if ( thePlayer ) then theBlip = createBlip( x, y, z, 49, 0, 0, 0, 255) setElementData( thePlayer, "tempdata.party", theBlip ) setElementData( thePlayer, "tempdata.patee", true ) if ( theBlip ) then outputChatBox("Marker created successfully", thePlayer) else outputChatBox("Failed to create a marker", thePlayer) end end addCommandHandler( "party", createPartyBlip ) function removePartyBlip (thePlayer) if ( getElementData(thePlayer, "tempdata.patee", true ) ) then destroyElement(getElementData(thePlayer,"tempdata.party", theBlip)) outputChatBox("Blip has been removed", thePlayer ) setElementData( thePlayer, "tempdata.patee", false ) end end end addCommandHandler( "partyremove", removePartyBlip ) but i dont understand why does it say the error all the time [2014-09-05 00:44:33] WARNING: scoreboardupdated\basiccommands.lua:22: Bad argument @ 'addCommandHandler' [Expected function at argument 2, got nil]
  10. Okay so I was attempting to create a function where I can create a blip on the map which I successfully accomplish then I wanted to either use the same command to make the marker and remove it but I failed miserably here is my result can someone explain me on how to do things like that btw here is the code I came up with in the end that doesen't work function createPartyBlip ( thePlayer, commandName ) if ( thePlayer ) then local x,y,z = getElementPosition (thePlayer) local theBlip = createBlip( x, y, z, 49, 0, 0, 0, 255) local theBlip0 = setElementData( thePlayer, "tempdata.party", theBlip ) local theBlip2 = setElementData ( thePlayer, "tempdata.partyblip", 1 ) local theBlip3 = setElementData ( thePlayer, "tempdata.partyblippy", x ) local theBlip4 = setElementData ( thePlayer, "tempdata.partyblippy", y ) local theBlip5 = setElementData ( thePlayer, "tempdata.partyblippy", z ) if ( theBlip ) then outputChatBox("Marker created successfully", thePlayer) else outputChatBox("Failed to create a marker", thePlayer) end end addCommandHandler( "party", createPartyBlip ) function removePartyBlip ( thePlayer, commandName ) if ( getElementData(thePlayer, "tempdata.partyblip", 1 ) ) then local blippe=getElementData(thePlayer, "tempdata.party" ) local blippy2=getElementData(thePlayer, "tempdata.partyblippy") local blippy3=getElementData(thePlayer, "tempdata.partyblippy") local blippy4=getElementData(thePlayer, "tempdata.partyblippy") setElementData(thePlayer, "tempdata.partyblip", 0) destroyElement(blippe, blippy2, blippy3, blippy4) outputChatBox("Blip has been removed", thePlayer ) end end end addCommandHandler( "partyremove", removePartyBlip ) If someone could correct this it would be a great learning experience for me since I learn from wiki and other scripts
  11. I was getting an idea of creating an iron miner job for my local server but I realised how am I going to store the iron in the database or in account data I really have no idea could someone explain me how to create an custom item (element) like getPlayerMoney but for iron so I can call it back to display the amount.
  12. Hi all im a new scripter and i have been having problems with a script for trouble in terrorist town i've got it to get a random player now i need it to draw traitor text to that random player how am i going to do that ( im scripting like 3,4 days ) here is what i tried and does not work function sendTraitor() local gRandomPlayer = getRandomPlayer() local traitor = outputChatBox("You are the traitor, "..getPlayerName(gRandomPlayer).."!", gRandomPlayer, 255, 255, 255, true) local gPlayers = getElementsByType("player") for placeNumber, playerData in ipairs(gPlayers) do if (playerData ~= gRandomPlayer) then outputChatBox("You are innocent! "..getPlayerName(gRandomPlayer).." is the traitor!", playerData, 255, 255, 255, true) function drawTraitor() if traitor then dxDrawText("TRAITOR", 1399, 929, 1796, 1024, tocolor(255, 255, 255, 255), 3.00, "pricedown", "left", "top", false, false, true, false, false) end function handleTheRendering addEventHandler ( "onClientRender", root, drawTraitor ) end end end end addCommandHandler( "ttt", sendTraitor ) addCommandHandler( "ttt", resourceRoot, handleTheRendering )
  13. It repairs the vehicle but it shows that "you need to be in a vehicle to repair" and "the vehicle has been repaired" at the same time [2014-06-28 01:11:48] WARNING: repairmarker\repmarker.lua:28: Bad argument @ 'getVehicleOccupant' [Expected vehicle at argument 1, got player] I don't understand this part: local t = getElementType(thePlayer) local vehicle if(t=="vehicle") then vehicle = thePlayer thePlayer = getVehicleOccupant(thePlayer) elseif(t=="player")then vehicle = getVehicleOccupant(thePlayer) end
  14. Hello all im new here on the forums and mainly in MTA scripting community im looking to become a professional scripter (i started scripting like 2 days ago) so the problem is i get these warnings [2014-06-27 23:50:22] WARNING: repairmarker\repmarker.lua:21: Bad argument @ 'getPedOccupiedVehicle' [Expected ped at argument 1, got vehicle] [2014-06-27 23:50:22] WARNING: repairmarker\repmarker.lua:22: Bad argument @ 'getPlayerMoney' [Expected player at argument 1, got vehicle] The script for markers and everything is : local repMarker = createMarker(2063.60, -1831.69, 12.5, 'cylinder', 2.0, 255, 0, 0, 150)---Near Grove Street Repair Marker local repMarker2 = createMarker(1024.80, -1025.40, 3.29, 'cylinder', 2.0, 255, 0, 0, 150)---Above saints hospital repair marker local repMarker3 = createMarker(487.79, -1739.59, 10.10, 'cylinder', 2.0, 255, 0, 0, 150)---Santa Maria Beach Marker local repMarker4 = createMarker(2076.30, -2546.80, 12.60, 'cylinder', 2.0, 255, 0, 0, 150)--LS Airport Repair Marker local repMarker5 = createMarker(-1262.5, -31.70, 13.19, 'cylinder', 2.0, 255, 0, 0, 150)---SF Airport Repair Marker local repMarker6 = createMarker(1523.69, 1720.09, 9.8, 'cylinder', 2.0, 255, 0, 0, 150)---LV Airport Repair Marker local repMarker7 = createMarker(2386.5, 1049.80, 9.8, 'cylinder', 2.0, 255, 0, 0, 150)---LV Repair Marker Near Gas Station local repMarker8 = createMarker(-1904.59, 283.70, 40, 'cylinder', 2.0, 255, 0, 0, 150)--SF Repair Marker @ Wang Cars local repMarker9 = createMarker(-1786.90, 1214.90, 24.10, 'cylinder', 2.0, 255, 0, 0, 150)--SF Repair Marker @ Expensive Car Shop local repMarker10 = createMarker(344.60, 2540.5, 15.80, 'cylinder', 2.0, 255, 0, 0, 150)--Abandoned Airport Repair Marker local repMarker11 = createMarker(1872.19, -2393.30, 12.60, 'cylinder', 2.0, 255, 0, 0, 150)--LS Airport Repair Marker 2 createBlipAttachedTo(repMarker, 63) createBlipAttachedTo(repMarker2, 63) createBlipAttachedTo(repMarker3, 63) createBlipAttachedTo(repMarker7, 63) createBlipAttachedTo(repMarker8, 63) createBlipAttachedTo(repMarker9, 63) function repairMarker(thePlayer, matchingDimension) local vehicle = getPedOccupiedVehicle ( thePlayer ) local payment = getPlayerMoney ( thePlayer ) if ( not vehicle) then outputChatBox( "You need to be in a vehicle to repair it!" , thePlayer, 255, 0, 0, true ) return end if ( payment >= 100 ) then takePlayerMoney( thePlayer, 100 ) fixVehicle( vehicle ) outputChatBox( "You have repaired your car", thePlayer, 255, 0, 0, true ) else outputChatBox( "You don't have enough money to repair your car", thePlayer, 255, 0, 0, true) end end addEventHandler( "onMarkerHit", repMarker, repairMarker) addEventHandler( "onMarkerHit", repMarker2, repairMarker) addEventHandler( "onMarkerHit", repMarker3, repairMarker) addEventHandler( "onMarkerHit", repMarker4, repairMarker) addEventHandler( "onMarkerHit", repMarker5, repairMarker) addEventHandler( "onMarkerHit", repMarker6, repairMarker) addEventHandler( "onMarkerHit", repMarker7, repairMarker) addEventHandler( "onMarkerHit", repMarker8, repairMarker) addEventHandler( "onMarkerHit", repMarker9, repairMarker) addEventHandler( "onMarkerHit", repMarker10, repairMarker) addEventHandler( "onMarkerHit", repMarker11, repairMarker) Btw everything seems to work the fixing and taking money but why am i getting these warnings i don't want to get the warnings every time someone enters a repair marker.
×
×
  • Create New...