Jump to content

liamknight24

Members
  • Posts

    35
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

liamknight24's Achievements

Rat

Rat (9/54)

0

Reputation

  1. chat bubbles worked, but got another problem i left the server for a day and didnt touch a thing and now the bots arnt working at all, Warning: bad argument @ setElementData and setPedStat
  2. thank you!!! but what about the gui controlling them?? edit: sorry it works fine thankyou!! Edit again : what about the bots talking?
  3. https://community.multitheftauto.com/index.php?p= ... ils&id=612 to change the acl just use your admin panel and click on the resources tab then click manage ACL. EDIT: i didnt realise i was too late
  4. hi everybody i tried using the gui from the cp gamemode to control bots as i wanted each player to have a bot that they can control, the only problem is that it dosent work , here is what i put together: Server: function spawnBot(pedname,player,pedweapon,pedskin) if isElement(player) then local team = getPlayerTeam(player) local randomnumber = math.random(1,#spawns) local randx = math.random(0,6)-3 local randy = math.random(0,6)-3 local newped = call(getResourceFromName("Slothbot"),"spawnBot",getElementData(spawns[randomnumber],"posX")+randx,getElementData(spawns[randomnumber],"posY")+randy,getElementData(spawns[randomnumber],"posZ"),getElementData(spawns[randomnumber],"rotZ"),pedskin,0,0,team,pedweapon,"waiting") setElementData(newped,"name",pedname) setElementData(newped,"squadleader",player) setElementData(newped,"pedteam",team) setElementData(newped,"pedweapon",pedweapon) setElementData(newped,"pedskin",pedskin) triggerClientEvent(player,"onClientSendSquadmembers",player,{newped}) end end addCommandHandler("onPlayerSpawn",getRootElement(), spawnBot) function botDied() local squadleader = getElementData(source,"squadleader") triggerClientEvent(squadleader,"onSquadmemberDie",source) for i,v in ipairs(getAttachedElements(source)) do destroyElement(v) end local killtimer = setTimer(spawnBot,respawntime,1,getElementData(source,"name"),squadleader,tonumber(getElementData(source,"pedweapon")),tonumber(getElementData(source,"pedskin"))) table.insert(botspawntimers,killtimer) end addEvent("onBotDied",true) addEventHandler("onBotDied",getRootElement(),botDied) addEvent("onBotWasted",true) addEventHandler("onBotWasted",getRootElement(),botDied) function quitHandler() for i,v in ipairs(getAttachedElements(source)) do destroyElement(v) end for i,v in ipairs(getElementsByType("ped")) do if getElementData(v,"squadleader") == player then for i1,v1 in ipairs(getAttachedElements(v)) do destroyElement(v1) end destroyElement(getElementData(v,"targetmarker")) destroyElement(v) end end end addEventHandler("onPlayerQuit",getRootElement(),quitHandler) function killFunction(player) killPed(player) end addCommandHandler("kill",killFunction) and the client: function markSquadPeds(peds) for i,v in ipairs(peds) do local marker = createMarker(0,0,0,"arrow",0.5,255,255,255,128) attachElements(marker,v) setElementAttachedOffsets(marker,0,0,1.5) createBlipAttachedTo(v,0,1,255,255,255,255,10,99999,getRootElement()) local targetmarker = createMarker(0,0,0,"corona",1.5,255,255,255,0) setElementData(v,"targetmarker",targetmarker) end end addEvent("onClientSendSquadmembers",true) addEventHandler("onClientSendSquadmembers",getRootElement(),markSquadPeds) function drawPedTags() for i,v in ipairs(getElementsByType("ped")) do local name = getElementData(v,"name") if name then local x,y,z = getElementPosition(v) local cx,cy,cz = getCameraMatrix() if isLineOfSightClear(cx,cy,cz,x,y,z,true,true,false,true,false,true,false,v) then if getDistanceBetweenPoints3D(cx,cy,cz,x,y,z) <= 45 then local px,py = getScreenFromWorldPosition(x,y,z+0.3,0.06) if px then local hp = getElementHealth(v) if hp > 0 then local width = dxGetTextWidth(name,1,default) local armor = getPedArmor(v) local r,g,b = 255,255,255 if getElementData(v,"pedteam") then r,g,b = getTeamColor(getElementData(v,"pedteam")) end local ucAlpha = 128 hp = hp * 7.52 hp = hp / ( 750 / 510 ) local lRed = 0 local lGreen = 0 if hp > 255 then lRed = 512 - hp if lRed < 0 then lRed = 0 end if lRed > 255 then lRed = 255 end lGreen = 255 elseif hp <= 255 then lRed = 255 lGreen = hp end -- nametags with shadow dxDrawText(name, px + 1, py + 1, px + 1, py + 1, tocolor(0, 0, 0, 255), 1, "default", "center", "center", false, false) dxDrawText(name, px, py, px, py, tocolor(r, g, b, 255), 1, "default", "center", "center", false, false) local lRedBlack = lRed * 0.33 local lGreenBlack = lGreen * 0.33 -- health and armor bar -- TR - TL - BR - BL local fHeight = sy * 0.011 local fWidth = sx * 0.060 local fTopOffset = sy * 0.025 local fSizeIncreaseBorder = sx * 0.003 local fRemovedWidth = fWidth - (hp / 512 * fWidth) local fMaxArmor = 100 local fArmorAlpha = ( armor / fMaxArmor ) * 255 -- Base rectangle local vecTopLeftBaseX = px - fWidth * 0.5 local vecTopLeftBaseY = py + fTopOffset local vecBotRightBaseX = px + fWidth * 0.5 local vecBotRightBaseY = py + fTopOffset + fHeight -- background local vecTopLeftX = vecTopLeftBaseX - fSizeIncreaseBorder local vecTopLeftY = vecTopLeftBaseY - fSizeIncreaseBorder local vecBotRightX = vecBotRightBaseX + fSizeIncreaseBorder local vecBotRightY = vecBotRightBaseY + fSizeIncreaseBorder dxDrawRectangle(vecTopLeftX, vecTopLeftY, vecBotRightX - vecTopLeftX, vecBotRightY - vecTopLeftY, tocolor(0, 0, 0, ucAlpha)) if armor > 0 then -- armor background vecTopLeftX = vecTopLeftBaseX - fSizeIncreaseBorder vecTopLeftY = vecTopLeftBaseY - fSizeIncreaseBorder vecBotRightX = vecBotRightBaseX + fSizeIncreaseBorder vecBotRightY = vecBotRightBaseY + fSizeIncreaseBorder dxDrawRectangle(vecTopLeftX, vecTopLeftY, vecBotRightX - vecTopLeftX, vecBotRightY - vecTopLeftY, tocolor(179, 177, 167, fArmorAlpha)) end -- the colored bit vecTopLeftX = vecTopLeftBaseX vecTopLeftY = vecTopLeftBaseY vecBotRightX = vecBotRightBaseX - fRemovedWidth vecBotRightY = vecBotRightBaseY dxDrawRectangle(vecTopLeftX, vecTopLeftY, vecBotRightX - vecTopLeftX, vecBotRightY - vecTopLeftY, tocolor(lRed, lGreen, 0, ucAlpha)) -- the black bit vecTopLeftX = vecTopLeftBaseX + fWidth - fRemovedWidth vecTopLeftY = vecTopLeftBaseY vecBotRightX = vecBotRightBaseX vecBotRightY = vecBotRightBaseY dxDrawRectangle(vecTopLeftX, vecTopLeftY, vecBotRightX - vecTopLeftX, vecBotRightY - vecTopLeftY, tocolor(lRedBlack, lGreenBlack, 0, ucAlpha)) end end end end end end end addEventHandler("onClientRender",getRootElement(),drawPedTags) local agreetable = { "affirmative", "positive", "understood", "got it", "alright", "aye", "i'm on it", "sure", "fine", "okay", } local localplayer = getLocalPlayer() function getCloseSquadMembers() local matches = {} for i,v in ipairs(getElementsByType("ped")) do if getElementData(v,"squadleader") == localplayer then local px,py,pz = getElementPosition(localplayer) local mx,my,mz = getElementPosition(v) if getDistanceBetweenPoints3D(px,py,pz,mx,my,mz) <= 15 then table.insert(matches,v) end end end return matches end function makePedFollow(income) doForAll(income,"doMakePedFollow",", follow") end function makePedWait(income) doForAll(income,"doMakePedWait",", wait") end function makePedStopFire(income) doForAll(income,"doMakePedStopFire",", hold fire") end function makePedStartFire(income) doForAll(income,"doMakePedStartFire",", open fire") end function makePedMoveTo(income) local x,y,z = getElementPosition(getElementData(localplayer,"targetmarker")) if isElement(income) then local marker = getElementData(income,"targetmarker") setElementPosition(marker,x,y,z) setMarkerColor(marker,255,255,255,128) triggerServerEvent("doMakePedMoveTo",localplayer,income,x,y,z) triggerEvent("onMessageIncome",income,agreetable[math.random(1,#agreetable)]..", move to position",0) elseif type(income) == "table" then for i,v in ipairs(income) do local marker = getElementData(v,"targetmarker") setElementPosition(marker,x,y,z) setMarkerColor(marker,255,255,255,42) triggerEvent("onMessageIncome",v,agreetable[math.random(1,#agreetable)]..", move to position",0) end triggerServerEvent("doMakePedMoveTo",localplayer,income,x,y,z) end end function makePedGuardHere(income) if isElement(income) then local x,y,z = getElementPosition(income) local marker = getElementData(income,"targetmarker") setElementPosition(marker,x,y,z) setMarkerColor(marker,255,255,255,128) triggerServerEvent("doMakePedGuardHere",localplayer,income,x,y,z) triggerEvent("onMessageIncome",income,agreetable[math.random(1,#agreetable)]..", guard here",0) elseif type(income) == "table" then for i,v in ipairs(income) do local x,y,z = getElementPosition(v) local marker = getElementData(v,"targetmarker") setElementPosition(marker,x,y,z) setMarkerColor(marker,255,255,255,128) triggerServerEvent("doMakePedGuardHere",localplayer,v,x,y,z) triggerEvent("onMessageIncome",v,agreetable[math.random(1,#agreetable)]..", guard here",0) end end end function makePedAttack(income) local attackers = getCloseSquadMembers() for i,v in ipairs(attackers) do triggerServerEvent("doMakePedAttack",localplayer,v,income) triggerEvent("onMessageIncome",v,agreetable[math.random(1,#agreetable)]..", attack",0) setMarkerColor(getElementData(v,"targetmarker"),255,255,255,0) end end function makePedGuard(income) local x,y,z = getElementPosition(getElementData(localplayer,"targetmarker")) if isElement(income) then local marker = getElementData(income,"targetmarker") setElementPosition(marker,x,y,z) setMarkerColor(marker,255,255,255,128) triggerServerEvent("doMakePedGuardPosition",localplayer,income,x,y,z) triggerEvent("onMessageIncome",income,agreetable[math.random(1,#agreetable)]..", guard position",0) elseif type(income) == "table" then for i,v in ipairs(income) do local marker = getElementData(v,"targetmarker") setElementPosition(marker,x,y,z) setMarkerColor(marker,255,255,255,42) triggerEvent("onMessageIncome",v,agreetable[math.random(1,#agreetable)]..", guard position",0) end triggerServerEvent("doMakePedGuardPosition",localplayer,income,x,y,z) end end function doForAll(unit,event,stringaddition) if isElement(unit) then triggerServerEvent(event,localplayer,unit) triggerEvent("onMessageIncome",unit,agreetable[math.random(1,#agreetable)]..stringaddition,0) setMarkerColor(getElementData(unit,"targetmarker"),255,255,255,0) elseif type(unit) == "table" then triggerServerEvent(event,localplayer,unit) for i,v in ipairs(unit) do triggerEvent("onMessageIncome",v,agreetable[math.random(1,#agreetable)]..stringaddition,0) setMarkerColor(getElementData(v,"targetmarker"),255,255,255,0) end end end but it dosent work i dont understand sorry, thanks for any help guys.
  5. old post but.. is it possible yet?
  6. hmm it still dosent work im stuck, is there any way to cancel the outputChatBox or hide the marker if there is already a timer if anybody can solve my problem. thanks again. *edit* please help people this does not work and I haven't got a clue why.
  7. I tried making a bank robbery script but it worked but the timer doesn't, I've never used timers before thanks for any help. function robmarkeronsetup () robmarker = createMarker (2277.99, -1729.04, 508.479, "cylinder", 4.5, 255, 0, 0, 128, getRootElement()) setElementInterior (robmarker, 3) end addEventHandler("onResourceStart", getRootElement(), robmarkeronsetup) function robm (hitPlayer, matchingDimension) if (source == robmarker) then outputChatBox ("****BANK ROB****", hitPlayer, 255, 0, 0, false) outputChatBox ("Press X To Rob The Bank!", hitPlayer, 255, 0, 0, false) outputChatBox ("You Must Wait To Get The Cash!", hitPlayer, 255, 0, 0, false) bindKey (hitPlayer, "x", "down", rob) end end addEventHandler("onMarkerHit", getRootElement(), robm) bankrob = {} function rob (thePlayer, key, keystate) if (key == "x") and (keystate == "down") then if isTimer(bankrob) then -- Check if timer is running using isTimer (this is an example of its use and all) end else outputChatBox ("***All Police To The Bank "..getPlayerName ( thePlayer ).. " Is Robbing The Bank*** ", getRootElement(), 255, 0, 0, false) bankrob = setTimer( robb, 100000, 1 ) function robb() givePlayerMoney ( thePlayer, math.random(50000, 100000) ) end end end function death() killTimer ( bankrob ) end addEventHandler ( "onPlayerWasted", getRootElement(), death ) p.s it is very basic at the moment and quickly made.
  8. hi i have made this script t try and save the "deaths" on the scoreboard but it dosent work, here it is function Quit(player) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local Deaths = getElementData ( source, "Deaths" ) if ( Deaths ) then setAccountData( playeraccount, "Deaths", Deaths ) end end end addEventHandler ( "onPlayerQuit", root, function() Quit() end ) function onPlayerConnect(player) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local Deaths = GetAccountData( playeraccount, "Deaths") if ( Deaths ) then setElementData ( source, Deaths ) end end end addEventHandler("onPlayerLogin", root, function () onPlayerConnect(source) end )
  9. cheers 50p. anybody know why this dosent work ? .. outputChatBox ( getPlayerName ( source ).. "has invited" .. otherplayer .. " to their team" "("..getPlayerTeam ( source )..")", otherplayer ) -- i want it to come out like this: "player" has invited "the other player" to their team (teamname) and only let the player from the command see it, i think the rest of the script is fine but something is messed up with this.
  10. how can i make a script that will write a car position to XML when the player types in a command? and how do i compile scripts, and is there any point?
  11. 50p thanks again, ive never wrote a client side script before are they just the save as server sripts but changed in the meta and use some differnt functions? and also in the script i need to setAccountData and according to the wiki its a server only function, and to get the players weapon from the slot it needs to be client side so is my script not possible or can i add an event that will trigger the server setAccountData function from the server side script but if this is possible how will the server know what data to set if they are not in the same script? or is there any other getting the slot server side? thanks for the reply if you understand what i mean.
  12. cheers 50p i have another problem if i want to get a players weapon from a slot would it be done like this : local weapon = getPlayerWeapon ( player, 3 ) hopefully trying to get a weapon from the player and from weapon slot 3?
  13. Go back to your out of sync crap MTA kicks sa-mp ass.
×
×
  • Create New...