Jump to content

Deep thinker

Members
  • Posts

    218
  • Joined

  • Last visited

Everything posted by Deep thinker

  1. hello, I am trying to make a script that stores armor if it's undamaged but i got some warnings in the line 10 in the client side here is the script ,it's very simple --Client Side function storeArmor ( ) local armor = getPedArmor( player ) if ( armor == 100 ) then return function () triggerServerEvent("setdaarmor",true) outputChatBox( "Your armor got stored",255,255,255,true ) end end end addCommandHandler ( "storearmor", showArmor ) -------------------------------------------------------------------------- addEvent("setdaarmor",true) addEventHandler("setdaarmor", resourceRoot, function() setPedArmor( 0, player ) end) thank you ,notice if i forgot something.
  2. i think i should use a better compare than mine ,my compare makes this 0.5 ,i have discovered this.
  3. Topic #1 i have a script for the police but there is a bug when they player is jailed it get it's crimes and he get jailed for ex : 3.5 second and the 0.5 doesn't count down and the player get stuck in jail ,this one make the player stuck for 3.5 3.75 and the 0.75 or the 0.5 don't count down, local seconds_left = 0 local sWidth, sHeight = guiGetScreenSize() local controls = {"fire","enter_exit","action","crouch","next_weapon","previous_weapon"} local pos = {} local client = getLocalPlayer() local cop local lawTeams = {["Police"]=true, ["SWAT"]=true, ["Military"] = true} chargesWindow = guiCreateWindow((sWidth/2)-365,(sHeight/2)-158,730,316,"T-RPG Police Database: The charges against you",false) guiSetAlpha(chargesWindow,0.95) guiSetVisible(chargesWindow, false) guiWindowSetSizable(chargesWindow,false) chargesGrid = guiCreateGridList(14,31,700,235,false,chargesWindow) guiGridListSetSelectionMode(chargesGrid,0) chargeColumn = guiGridListAddColumn(chargesGrid,"Charge",0.95) closeButton = guiCreateButton(308,274,115,30,"Close",false,chargesWindow) addEventHandler("onClientGUIClick", closeButton, function() guiGridListClear(chargesGrid) guiSetVisible(chargesWindow, false) showCursor(false) end, false) function drawJailTime() dxDrawBorderedText(seconds_left.." seconds remaining.",(653/1024)*sWidth,(678/768)*sHeight,(1010/1024)*sWidth,(725/768)*sHeight,tocolor(50,150,255,255),(sWidth/1024)*2.0,"sans","left","top",false,false,false) end function dxDrawBorderedText( text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI ) dxDrawText ( text, x - 1, y - 1, w - 1, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) -- black dxDrawText ( text, x + 1, y - 1, w + 1, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x - 1, y + 1, w - 1, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x + 1, y + 1, w + 1, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x - 1, y, w - 1, h, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x + 1, y, w + 1, h, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y - 1, w, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y + 1, w, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI ) end addEvent("startJailCounter", true) addEventHandler("startJailCounter", client, function (theTime, crimes, x, y, z, bool) pos[1], pos[2], pos[3] = x, y, z if theTime < 1000.5 then seconds_left = 0.5 else seconds_left = theTime/1000.5 end jailTimer = setTimer(minusOneForCounter, 1000, seconds_left) addEventHandler("onClientRender", root, drawJailTime) for ind, ent in pairs(crimes) do if (ent[1] == "1") then theString = ent[1].." Count of "..ent[2].." commit a total of "..ent[3].." times in life." else theString = ent[1].." Counts of "..ent[2].." commit a total of "..ent[3].." times in life." end local row = guiGridListAddRow(chargesGrid) guiGridListSetItemText(chargesGrid, row, chargeColumn, theString, false, false) end guiSetVisible(chargesWindow, true) showCursor(true) disableTimer = setTimer(toggleControlsInJail, 1000, seconds_left - 1, false) end) function minusOneForCounter() if (seconds_left == 1) then removeEventHandler("onClientRender", root, drawJailTime) triggerServerEvent("releasePlayerFromJail", client, client, pos[1], pos[2], pos[3]) toggleControlsInJail(true) else seconds_left = seconds_left - 1 setElementData(localPlayer,"jailTime",tonumber(seconds_left*1000)) end end function antiJailDamage() if (isTimer(jailTimer)) then cancelEvent() end end addEventHandler("onClientPlayerDamage", client, antiJailDamage) function toggleControlsInJail(bool) for ind, control in pairs(controls) do toggleControl(control, bool) end end function release() removeEventHandler("onClientRender", root, drawJailTime) triggerServerEvent("releasePlayerFromJail", client, client, pos[1], pos[2], pos[3]) if isTimer(jailTimer) then killTimer(jailTimer) end if isTimer(disableTimer) then killTimer(disableTimer) end for ind, control in pairs(controls) do toggleControl(control, true) end end addEvent("releaseJ",true) addEventHandler("releaseJ",getRootElement(),release) addEvent("onClientPlayerLogout",true) addEventHandler("onClientPlayerLogout",root, function () if isTimer(jailTimer) then killTimer(jailTimer) end removeEventHandler("onClientRender", root, drawJailTime) seconds_left = 0 end) local policeStationLocations = { {X=2246.100830, Y=2453.19531, Z=9.8203}, {X=-1406.90722, Y=2655.09277, Z=55.6875}, {X=-209.9542, Y=977.7558, Z=18.1889}, {X=-1628.26196, Y=676.620056, Z=6.190120}, {X=624.66278, Y=-605.72027, Z=15.923292}, {X=1536.264, Y=-1675.483, Z=12.0}, {X=-2164.37792, Y=-2389.53320, Z=29.61720}, {X=135.560, Y=1949.906, Z=18.3} } local blip = {} local marker = {} function createArrestZones(alpha) if (alpha == 255) then for index, entry in pairs(policeStationLocations) do blip[index] = createBlip(entry.X, entry.Y, entry.Z, 30, 3, 0, 0, 255, 255) setBlipColor(blip[index], 0, 0, 0, 0) marker[index] = createMarker(entry.X, entry.Y, entry.Z, "cylinder", 6, 0, 0, 255, 200) end else for index, entry in pairs(blip) do if (entry and isElement(entry)) then destroyElement(entry) end end for index, entry in pairs(marker) do if (entry and isElement(entry)) then destroyElement(entry) end end end end addEvent("showArrestZones", true) addEventHandler("showArrestZones", client, createArrestZones) local cop = nil local prisoner = getLocalPlayer() function walkThePrisoner() if(getPedOccupiedVehicle(prisoner) == false) then local copX, copY, copZ = getElementPosition(cop) local prisonerX, prisonerY, prisonerZ = getElementPosition(prisoner) local copDim = getElementDimension(cop) local copInt = getElementInterior(cop) local crimDim = getElementDimension(prisoner) local crimInt = getElementInterior(prisoner) local copAngle = (360 - math.deg(math.atan2((copX - prisonerX),(copY - prisonerY))))%360 setPedRotation(prisoner, copAngle) setCameraTarget(prisoner, prisoner) if (copDim ~= crimDim or copInt ~= crimInt) then triggerServerEvent("setPrisonerInterior", prisoner, cop, copDim, copInt, copX, copY, copZ) end local dist = getDistanceBetweenPoints2D(copX, copY, prisonerX, prisonerY) if(dist > 35) then triggerServerEvent("freePlayer",prisoner,prisoner) removeEventHandler("onClientPreRender",getRootElement(),walkThePrisoner) elseif (dist > 15) then setControlState("sprint", false) setControlState("walk", false) setControlState("forwards", true) setControlState("jump", true) elseif (dist > 10) then setControlState("sprint", true) setControlState("walk", false) setControlState("forwards", true) setControlState("jump", false) elseif (dist > 5) then setControlState("sprint", false) setControlState("walk", false) setControlState("forwards", true) setControlState("jump", false) elseif (dist > 1.5) then setControlState("sprint", false) setControlState("walk", true) setControlState("forwards", true) setControlState("jump", false) elseif (dist < 1.5) then setControlState("sprint", false) setControlState("walk", false) setControlState("forwards", false) setControlState("jump", false) end local vehicle = getPedOccupiedVehicle(cop) if (vehicle) then triggerServerEvent("gotoVehicle",prisoner,cop,prisoner) end end end addEvent("onClientPlayerArrested", true) addEventHandler("onClientPlayerArrested", getLocalPlayer(), function(Cop) cop = Cop addEventHandler("onClientPlayerDamage",localPlayer,cancelEvent) addEventHandler("onClientPreRender",getRootElement(),walkThePrisoner) end ) addEvent("onClientPlayerEscaped", true) addEventHandler("onClientPlayerEscaped", getLocalPlayer(), function() cop = nil removeEventHandler("onClientPlayerDamage",getLocalPlayer(),cancelEvent) removeEventHandler("onClientPreRender",getRootElement(),walkThePrisoner) end ) addEvent("onClientPlayerJailed", true) addEventHandler("onClientPlayerJailed", getLocalPlayer(), function() cop = nil removeEventHandler("onClientPlayerDamage",getLocalPlayer(),cancelEvent) removeEventHandler("onClientPreRender",getRootElement(),walkThePrisoner) end ) function showPlayerCharges(crimes, message) if (message and message == "T-RPG Police Database: Your criminal record") then guiSetText(chargesWindow, message) for ind, ent in pairs(crimes) do if (ent[1] == "1") then theString = ent[1].." Count of "..ent[2].."." else theString = ent[1].." Counts of "..ent[2].."." end local row = guiGridListAddRow(chargesGrid) guiGridListSetItemText(chargesGrid, row, chargeColumn, theString, false, false) end else guiSetText(chargesWindow, "Terrible RPG charges against you") for ind, ent in pairs(crimes) do if (ent[1] == "1") then theString = ent[1].." Count of "..ent[2].." worth "..ent[4].." seconds in prison." else theString = ent[1].." Counts of "..ent[2].." worth "..ent[4].." seconds in prison." end local row = guiGridListAddRow(chargesGrid) guiGridListSetItemText(chargesGrid, row, chargeColumn, theString, false, false) end end guiSetVisible(chargesWindow, true) showCursor(true) end addEvent("showCharges", true) addEventHandler("showCharges", client, showPlayerCharges) function doBeanBag(attacker, weapon) if (attacker and weapon == 25 or weapon == 27) then if getElementData(attacker, "beanbagRound") then if getPlayerTeam(attacker) and not lawTeams[getTeamName(getPlayerTeam(attacker))] then setElementData(attacker, "beanbagRound", false) return end cancelEvent() toggleAllControls(false, true, false) setTimer(toggleAllControls, 4000, 1, true, true, false) exports["(SAUR)Info"]:sendClientMessage("You were shot with a bean bag by the police.", 255, 100, 0) end end end addEventHandler("onClientPlayerDamage", localPlayer, doBeanBag) function weaponSwitch(previousWeaponID, currentWeaponID) local teamName = getTeamName(getPlayerTeam(localPlayer)) if lawTeams[teamName] then if currentWeaponID ~= 25 and currentWeaponID ~= 27 then return end if getElementData(client, "beanbagRound") then exports["(SAUR)Info"]:sendClientMessage("Bean bag: Press SPACE while using a Shotgun to use a lethal bean bag rounds.", 255, 50, 0) else exports["(SAUR)Info"]:sendClientMessage("Bean bag: Press SPACE while using a Shotgun to use a non lethal bean bag round.", 0, 255, 0) end end end addEventHandler("onClientPlayerWeaponSwitch", client, weaponSwitch) Topic #2 the second topic talks about saving the walk style ,it doesn't get saved. actually i didn't make it someone gave it to me. function saveWalkStyle() local acc = getPlayerAccount(source) if acc and not isGuestAccount(acc) then local walk = getPedWalkingStyle (source) setAccountData(acc, "walkStyle", tonumber(walk)) end end addEventHandler("onPlayerQuit", root, saveWalkStyle) function loadWalkStyle(_, acc) local walk = getAccountData(acc, "wstyle") or 0 setPedWalkingStyle(source, tonumber(walk)) end addEventHandler("onPlayerLogin", root, loadWalkStyle)
  4. exactly notice: i couldn't rotate the weapon. can we talk in pm ? i want to show you the full script
  5. alright but now the weapon only shown and damage 1 player i want to make it for the hole players.
  6. actually i tried to use getPedOccupiedVehicle it worked but attaching the elements didn't work at all addCommandHandler("bobo", function () local position = Vector3(getElementPosition (localPlayer)) local weapon = createWeapon( 'minigun',position.x, position.y, position.z + 3 ); if ( isCar ) then local car = getPedOccupiedVehicle ( source ) attachElements ( weapon, car, 0, 0, 1, 0, 90, 0 ) end there is anther parts but i just posted what i need
  7. i know what are you talking about but i am not sure about the part i typed ,if you checked that part ,it checks if the ped in vehicle or not ?
  8. actually it works efficiently :3 but i want to check if the player is in vehicle then attach the minigun into the car
  9. i think you should use bool isPedInVehicle ( ped thePed ) i am not sure about this but try it if isPedInVehicle ( source ) then attachElements ( speakerBox [ source ], source, 0, 2, 0 ) if it's wrong then i am sorry ,i would like to help but i am not expire enough .
  10. as IPrestege taught me before it's would be better to use the client side
  11. hello i was making a script which is depending on the rotation but i was trying to rotate it when i press a button the full script is to create a minigun and attach it to the player's body and allow him to rotate the weapon without aiming it. function createMinigunWeapon() -- Create the weapon 1 meter above the player local x, y, z = getElementPosition(getLocalPlayer()) local weapon = createWeapon("minigun", x, y, z + 5) local rotX, rotY, rotZ = getElementRotation(weapon) bindKey("num_6","down", function() setElementRotation(weapon,0,0,rotZ+10) end ) also i have read the wiki ,i tried to follow its instructions but i totally failed :3 notice : i have just posted the part i need in the script
  12. actually you said " How i can make one like SAUR one :v " so like refers to images.(also i have checked your last posts and you are using stolen server resource,i was depending on this ) any ways i tried to message soildsnake14 and waiting for answer.
  13. 100% it's not allowed. it's like copying or stealing a script .(You can be reported for that )
  14. hello i was working on a small script which attach the star icon if the player is wanted but i got a debug output it said that there is a bug in the compare in line #3 here is the script ,i think i should change the Event "onResourceStart" function wanted() local wanted = getPlayerWantedLevel(player) if ( wanted > 0 ) then x, y, z = getElementPosition(player) i = getElementInterior(player) d = getElementDimension(player) wantedpickup = createObject( 1247, x, y, z+1, i, d ) attachElements( wanted , player ) end end addEventHandler("onResourceStart",root,wanted) also i had anther script which can't find a file in its meta file "saur.png" <meta> <info author="ProMax" type="script" version="2.0" name="staff-tag" description="Simple Staff Tag Script" /> <script src="client.lua" type="client"/> <file src="saur.png"/> </meta> function renderStaffTag() local streamedPlayers = getElementsByType ("player", root, true) local lpos = {getElementPosition(localPlayer)} for _,p in ipairs (streamedPlayers) do if p and isElement (p) then if not getPlayerTeam(p) or getPlayerTeam(p) ~= getTeamFromName("Staff") then return end if streamedPlayers and #streamedPlayers ~= 0 then local ppos = {getElementPosition(p)} if getDistanceBetweenPoints3D (lpos[1], lpos[2], lpos[3], ppos[1], ppos[2], ppos[3]) <= 20 then local x, y = getScreenFromWorldPosition (ppos[1], ppos[2], ppos[3]+1.2) if x and y then dxDrawText ("Staff Member", x+1, y+1, x, y, tocolor (0, 0, 0), 1, "pricedown", "center") dxDrawText ("Staff Member", x, y, x, y, tocolor (52, 0, 66), 1, "pricedown", "center") end end end end end end addEventHandler ("onClientRender", root, renderStaffTag) also if someone can add a part which draw an image in the game attached to the player with name "saur.png" Thanks
  15. then switch the teams Unemployed should be in Police's team postion
  16. in the first part i have already added the code which disabled death for (Unemployed , Civilian,Emergency ) then why did you disable death for him again. also you didn't explain anything about what you have done.
  17. function toggleFRWindow() if isPlayerInACL(thePlayer, "Admin") then if isWindowOpen(wndMain) then showCursor(false) hideAllWindows() colorPicker.closeSelect() else showCursor(true) showAllWindows() end end end addCommandHandler('fr', toggleFRWindow) failed :3
  18. hello, i am promax and i am scripting disable killing between two teams ( Military , Police ) ,i have tried to make it but i have failed 100% :3 ,i just knew the functions from an ex post ,but it wasn't useful that much but it was maded by Iprestege (Fahad) he helped me lil a bit ,also taught me some new functions and i appreciate what he have done for me, the script that he gave me --this was my first try to make these teams can't get killed. local team = getTeamFromName (getLocalPlayer()) addEventHandler ( 'onClientPlayerDamage',root, function () if ( team == "Unemployed" ) or ( team == "Off Duty Workers" ) or ( team == "Civilian" ) or ( team == "Emergency" ) then if getElementData ( Player, "team" ) then cancelEvent() end end end ) ---------------------------------------------------------------------------------------------------------------------- --that was Iprestege's one addEventHandler ( 'onClientPlayerDamage',localPlayer, function ( aAttacker ) if ( aAttacker and getElementType ( aAttacker ) == 'player' and aAttacker ~= source ) then local aLocalTeam = getPlayerTeam ( source ) local aAttackerTeam = getPlayerTeam ( aAttacker ) if ( aLocalTeam and aAttackerTeam ) then if ( aLocalTeam == getTeamFromName ( 'Unemployed' ) and aAttackerTeam == getTeamFromName ( 'Police' ) ) then cancelEvent ( ) end end end end ) my question here ,how can i use table in Iprestege's one for the aAttackerTeam and aLocalTeam thank you :3
  19. actually the last code works,i would like to thank you for your efforts but i need to know something else ,i want to make the freeroam panel only for admin ACL,if you can it would be great
  20. it's not working + it didn't create anything . also what is the point of this also i want it to be depending on account name not the player's name
  21. hi ,i have scripted a gate depending on account name , but i have started it ,it creates the marker and the object but the object isn't moving door = createObject ( 3089, 2004.5 , -1280 , 36.900001525879 , 0, 0, 0 ) marker = createMarker ( 2005.5 , -1280 , 35.900001525879 , 'cylinder', 1, 0, 0, 0, 255 ) -- after creating function openForProMax() local thePlayer = getAccountPlayer ( promax ) -- get the client attached to the account if ( getElementType ( thePlayer ) == "player" ) then moveObject ( door,2000, 2004.5 , -1280 , 30.900001525879, 0, 0, 0 ) else return end end addEventHandler ( 'onMarkerHit', marker, openForProMax ) function closeAfterProMax() moveObject ( door,2000, 2004.5 , -1280 , 36.900001525879, 0, 0, 0 ) end addEventHandler ( 'onMarkerLeave', marker, closeAfterProMax )
  22. oh yea about the server and client functions ,i do mix between them a lot ,thank you for noticing i will edit it and contact you with news. now i have added these functions to the server side and triggered it ,now every one can use F1 also it created a bug and now i can't spawn anything -- server part addEvent("onPlayerJoin",true) addEventHandler("onPlayerJoin",g_root, function () if not player then player = source end local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) -- get his account name if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then -- Does he have access to Admin functions? g_PlayerData[player] = { vehicles = {} } g_PlayerData[player].blip = createBlipAttachedTo(player, 0, 2, r, g, b) if g_FrozenTime then clientCall(player, 'setTimeFrozen', true, g_FrozenTime[1], g_FrozenTime[2], g_FrozenWeather) end end end) addEventHandler('onClientResourceStart', g_ResRoot, function() triggerServerEvent("onPlayerJoin", g_root) setTimer(getPlayers, 1000, 1) bindKey('f1', 'down', toggleFRWindow) createWindow(wndMain) hideAllWindows() guiCheckBoxSetSelected(getControl(wndMain, 'jetpack'), doesPedHaveJetPack(g_Me)) guiCheckBoxSetSelected(getControl(wndMain, 'falloff'), canPedBeKnockedOffBike(g_Me)) setJetpackMaxHeight ( 9001 ) triggerServerEvent('onLoadedAtClient', g_ResRoot) end ) and this line got a nil value if i > getOption('vehicles.maxperplayer') then you will find it in your own freeroam resource in line 344 maybe
×
×
  • Create New...