Jump to content

ADCX

Members
  • Posts

    79
  • Joined

  • Last visited

Everything posted by ADCX

  1. New version released: 1.0.2 Changes: - Added option to also display gangs as teams - Corrected grammatical mistakes in exported functions' documentations - Fixed small bug with exported functions
  2. I haven't added that function yet, but I'm preparing a new release today and if I have any more extra time, I'll add it.
  3. ADCX

    Weapon tables

    Table = {"something" = {"something else" = {1 = "hello", 2 = "goodbye"}}} local Something = Table["something"] local SomethingElse = Something["something else"] Hello = SomethingElse[1]
  4. Thanks, Dealman. I'm not planning to make an update just yet, but when I do I'll consider those changes.
  5. car1 = createVehicle ( 540, x, y, z ) car2 = createVehicle ( 540, x, y, z ) car3 = createVehicle ( 540, x, y, z ) function enterVehicle ( thePlayer, seat, jacked ) if not (getTeamName(getPlayerTeam(thePlayer)) == "MyTeam") then if (source == car1) or (source == car2) or (source == car3) then cancelEvent() end end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle )
  6. REMOVED FOR NOW, PART OF A LARGER PROJECT NOW (full uncompiled version on sale now: www.scriptmta.co.nr)
  7. Sorry, actually you can't do it. This function only executes command that is inside the lua file, not the hardcoded ones, so the only way you could make a shortcut for 'debugscript 3' is to bind it to a key in MTA console, if even that is possible.
  8. ADCX

    Weapon tables

    I'm not sure if that will work, but you can do something like this. Table = {} Table["something"] = {} local Table2 = Table["something"] Table2["something else"] = 11 Table["something"] = Table2
  9. function activateDebug3() if (isDebugViewActive()) then executeCommandHandler("debugscript","0") else executeCommandHandler("debugscript","3") end end addCommandHandler("db3",activateDebug3)
  10. ADCX

    Weapon tables

    TableOfTables= {} function CreatePlayerTable(Player) TableOfTables[Player] = {} end
  11. Variable theTimer is local to the function test, so you cannot use it inside the function within the timer. Pass it with a timer and then use it.
  12. ADCX

    Weapon tables

    function RemoveUnmatchedWeapon(Player,Table) for Slot = 0,12 do local WeaponID = getPedWeapon(Player,Slot) if not (WeaponID == Table[Slot]) then takeWeapon(Player,WeaponID) end end end function GetWeaponsTable(Player) local Table = {} for Slot = 0,12 do Table[Slot] = getPedWeapon(Player,Slot) end return Table end To get player's weapons table use GetWeaponsTable, and to remove weapons of other player that don't match use RemoveUnmatchedWeapon.
  13. function sayHandler( message, msgType ) ... local AnimationDuration = 1000 -- Measure your animation's duration in miliseconds setPedAnimation( source, "PED", "IDLE_CHAT", 1, false, true, true, true, false ) setTimer(setPedAnimation,AnimationDuration,1,source) ... end addEventHandler( "onPlayerChat", getRootElement(), sayHandler ) You don't have to use the variable AnimationDuration, I did it just to point it out. Anyway, to stop the player's animation, you use setPedAnimation without specifying animation block and name.
  14. function fncPlayerJoin() local ServerIP = "123.45.67.890" -- Server IP stored as a string local ServerPort = 12345 -- Server Port stored as an integer redirectPlayer(source,ServerIP,ServerPort) end addEventHandler("onPlayerJoin",getRootElement(),fncPlayerJoin) Put it in the server-sided script file.
  15. ADCX

    Not working.

    You're welcome.
  16. ADCX

    RP Projekt!

    To je bilo u slucaju Valhalle, kolko ja znam. Ali postoji nacin da se rjesi problem DDoS-a ako se koriste high-bandwidth server.
  17. ADCX

    Not working.

    Server: function onQuit () local account = getPlayerAccount (source) if ( account ) then local x,y,z = getElementPosition (source) setAccountData (account, "funmodev2-money", getPlayerMoney (source)) setAccountData (account, "funmodev2-skin", getElementModel (source)) setAccountData (account, "funmodev2-health", getElementHealth (source)) setAccountData (account, "funmodev2-armor", getPedArmor (source)) setAccountData (account, "funmodev2-R", r) setAccountData (account, "funmodev2-G", g) setAccountData (account, "funmodev2-B", b) setAccountData (account, "funmodev2-x", x) setAccountData (account, "funmodev2-y", y) setAccountData (account, "funmodev2-z", z) setAccountData (account, "funmodev2-int", getElementInterior (source)) setAccountData (account, "funmodev2-dim", getElementDimension (source)) setAccountData (account, "funmodev2-wantedlevel", getPlayerWantedLevel (source)) setAccountData (account, "funmodev2-weaponID0", getPedWeapon (source, 0)) setAccountData (account, "funmodev2-weaponID1", getPedWeapon (source, 1)) setAccountData (account, "funmodev2-weaponID2", getPedWeapon (source, 2)) setAccountData (account, "funmodev2-weaponID3", getPedWeapon (source, 3)) setAccountData (account, "funmodev2-weaponID4", getPedWeapon (source, 4)) setAccountData (account, "funmodev2-weaponID5", getPedWeapon (source, 5)) setAccountData (account, "funmodev2-weaponID6", getPedWeapon (source, 6)) setAccountData (account, "funmodev2-weaponID7", getPedWeapon (source, 7)) setAccountData (account, "funmodev2-weaponID8", getPedWeapon (source, -- s8) -->) setAccountData (account, "funmodev2-weaponID9", getPedWeapon (source, 9)) setAccountData (account, "funmodev2-weaponID10", getPedWeapon (source, 10)) setAccountData (account, "funmodev2-weaponID11", getPedWeapon (source, 11)) setAccountData (account, "funmodev2-weaponID12", getPedWeapon (source, 12)) setAccountData (account, "funmodev2-weaponAmmo0", getPedTotalAmmo (source, 0)) setAccountData (account, "funmodev2-weaponAmmo1", getPedTotalAmmo (source, 1)) setAccountData (account, "funmodev2-weaponAmmo2", getPedTotalAmmo (source, 2)) setAccountData (account, "funmodev2-weaponAmmo3", getPedTotalAmmo (source, 3)) setAccountData (account, "funmodev2-weaponAmmo4", getPedTotalAmmo (source, 4)) setAccountData (account, "funmodev2-weaponAmmo5", getPedTotalAmmo (source, 5)) setAccountData (account, "funmodev2-weaponAmmo6", getPedTotalAmmo (source, 6)) setAccountData (account, "funmodev2-weaponAmmo7", getPedTotalAmmo (source, 7)) setAccountData (account, "funmodev2-weaponAmmo8", getPedTotalAmmo (source, -- s8) -->) setAccountData (account, "funmodev2-weaponAmmo9", getPedTotalAmmo (source, 9)) setAccountData (account, "funmodev2-weaponAmmo10", getPedTotalAmmo (source, 10)) setAccountData (account, "funmodev2-weaponAmmo11", getPedTotalAmmo (source, 11)) setAccountData (account, "funmodev2-weaponAmmo12", getPedTotalAmmo (source, 12)) end Removeblip(source) end addEventHandler ("onPlayerQuit", getRootElement(), onQuit) local spawnLocations = { {2171.90625, 1392.59765625, 10.8203125}, {2265.3674316406, 2398.3068847656, 10.8203125}, {2361.689453125, 2070.2077636719, 10.671875}, {2087.9260253906, 1448.8768310547, 10.8203125}, {2000.55, 1526.25, 14.6171875}, {1607.35, 1816.54, 10.82} } StartMoney = 2500 CashForKill = 2500 PayNSprayCost = 100 playerSkin = {} Garages = {0,1,2,3,4,5,6,7,8,9,10, 11,12,13,14,15,16,17,18,19,20, 21,22,23,24,25,26,27,28,29,30, 31,32,33,34,35,36,37,38,39,40, 41,42,43,44,45,46,47,48,49,50, 51,52,53,54,55,56,57,58,59,60} function SpawnPlayer(thePlayer,skin,r,g,b) playerblip = {} local theCurrentAccount = getPlayerAccount(thePlayer) local accountData = getAccountData (theCurrentAccount, "funmodev2-money") if (accountData) then local playerSkin = getAccountData (theCurrentAccount, "funmodev2-skin") local playerHealth = getAccountData (theCurrentAccount, "funmodev2-health") local playerArmor = getAccountData (theCurrentAccount, "funmodev2-armor") local playerR = getAccountData (theCurrentAccount, "funmodev2-R") local playerG = getAccountData (theCurrentAccount, "funmodev2-G") local playerB = getAccountData (theCurrentAccount, "funmodev2-B") local playerB = getAccountData (theCurrentAccount, "funmodev2-B") local playerX = getAccountData (theCurrentAccount, "funmodev2-x") local playerY = getAccountData (theCurrentAccount, "funmodev2-y") local playerZ = getAccountData (theCurrentAccount, "funmodev2-z") local playerInt = getAccountData (theCurrentAccount, "funmodev2-int") local playerDim = getAccountData (theCurrentAccount, "funmodev2-dim") local playerWanted = getAccountData (theCurrentAccount, "funmodev2-wantedlevel") local playerWeaponID0 = getAccountData (theCurrentAccount, "funmodev2-weaponID0") local playerWeaponID1 = getAccountData (theCurrentAccount, "funmodev2-weaponID1") local playerWeaponID2 = getAccountData (theCurrentAccount, "funmodev2-weaponID2") local playerWeaponID3 = getAccountData (theCurrentAccount, "funmodev2-weaponID3") local playerWeaponID4 = getAccountData (theCurrentAccount, "funmodev2-weaponID4") local playerWeaponID5 = getAccountData (theCurrentAccount, "funmodev2-weaponID5") local playerWeaponID6 = getAccountData (theCurrentAccount, "funmodev2-weaponID6") local playerWeaponID7 = getAccountData (theCurrentAccount, "funmodev2-weaponID7") local playerWeaponID8 = getAccountData (theCurrentAccount, "funmodev2-weaponID8") local playerWeaponID9 = getAccountData (theCurrentAccount, "funmodev2-weaponID9") local playerWeaponID10 = getAccountData (theCurrentAccount, "funmodev2-weaponID10") local playerWeaponID11 = getAccountData (theCurrentAccount, "funmodev2-weaponID11") local playerWeaponID12 = getAccountData (theCurrentAccount, "funmodev2-weaponID12") local playerWeaponAmmo0 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo0") local playerWeaponAmmo1 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo1") local playerWeaponAmmo2 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo2") local playerWeaponAmmo3 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo3") local playerWeaponAmmo4 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo4") local playerWeaponAmmo5 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo5") local playerWeaponAmmo6 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo6") local playerWeaponAmmo7 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo7") local playerWeaponAmmo8 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo8") local playerWeaponAmmo9 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo9") local playerWeaponAmmo10 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo10") local playerWeaponAmmo11 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo11") local playerWeaponAmmo12 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo12") spawnPlayer ( thePlayer, playerX, playerY, playerZ + 2, 90.0, skin ,playerInt, playerDim ) giveWeapon(source, playerWeaponID0, playerWeaponAmmo0, true) giveWeapon(source, playerWeaponID1, playerWeaponAmmo1, false) giveWeapon(source, playerWeaponID2, playerWeaponAmmo2, false) giveWeapon(source, playerWeaponID3, playerWeaponAmmo3, false) giveWeapon(source, playerWeaponID4, playerWeaponAmmo4, false) giveWeapon(source, playerWeaponID5, playerWeaponAmmo5, false) giveWeapon(source, playerWeaponID6, playerWeaponAmmo6, false) giveWeapon(source, playerWeaponID7, playerWeaponAmmo7, false) giveWeapon(source, playerWeaponID8, playerWeaponAmmo8, false) giveWeapon(source, playerWeaponID9, playerWeaponAmmo9, false) giveWeapon(source, playerWeaponID10, playerWeaponAmmo10, false) giveWeapon(source, playerWeaponID11, playerWeaponAmmo11, false) giveWeapon(source, playerWeaponID12, playerWeaponAmmo12, false) end setCameraTarget (source, source) playerblip[source] = createBlipAttachedTo(source,0,2,r,g,b) setPlayerMoney(source,accountData) playerSkin[source] = {skin,r,g,b} setElementData(source,"Score",0) setPlayerNametagShowing ( source, false) end addEvent( "onClientWantsToSpawn", true ) addEventHandler( "onClientWantsToSpawn", getRootElement(), SpawnPlayer ) function Removeblip(player) destroyElement(playerblip[player]) end function PlayerDied(ammo,killer) if killer and getElementType ( killer ) == "player" then setPlayerMoney(killer,getPlayerMoney(killer)+CashForKill) local Score = getElementData(killer,"Score") setElementData(killer,"Score",Score+1) end setTimer(PlayerRespawn,1000,1,source) end addEventHandler("onPlayerWasted",getRootElement(),PlayerDied) function PlayerRespawn(diedPlayer) if not diedPlayer then else toggleAllControls(diedPlayer,true) setPlayerMoney(diedPlayer,StartMoney) local chosenSpawnLocation = math.random(1,#spawnLocations) spawnPlayer(diedPlayer,spawnLocations[chosenSpawnLocation][1],spawnLocations[chosenSpawnLocation][2],spawnLocations[chosenSpawnLocation][3],90,playerSkin[diedPlayer][1]) setCameraTarget (diedPlayer, diedPlayer) end end function FixPlayerVehicle(hitElement,number) local money = getPlayerMoney(hitElement) if money < PayNSprayCost then outputChatBox("*PM: You don't have enought cash.",hitElement,170,0,0,true) else if getPedOccupiedVehicle(hitElement) then local vehicle = getPedOccupiedVehicle(hitElement) fixVehicle(vehicle) playSoundFrontEnd(hitElement,16) toggleAllControls(hitElement,false) setPlayerMoney(hitElement,money-PayNSprayCost) local vehicle = getPedOccupiedVehicle(hitElement) setElementFrozen(vehicle,true) setTimer(function() toggleAllControls(hitElement,true) setCameraTarget (hitElement, hitElement) setElementFrozen(vehicle,false) end,2500,1) if number == 1 then setCameraMatrix(hitElement,1032.7685546875,-1039.337890625,45.220012664795,1030.095703125,-1027.6357421875,40.220008850098) elseif number == 2 then setCameraMatrix(hitElement,489.150390625,-1728.8310546875,31.169326782227,488.6884765625,-1734.04296875,21.179261207581) elseif number == 3 then setCameraMatrix(hitElement,2076.5859375,-1831.4208984375,18.546875,2072.626953125,-1831.361328125,18.546875) else end end end end addEvent( "onBoughtWeapon", true ) addEventHandler( "onBoughtWeapon", getRootElement(), function(thePlayer,id,cash) setPlayerMoney(thePlayer,getPlayerMoney(thePlayer)-cash) if id == 500 then setPedArmor ( thePlayer, 100 ) else giveWeapon ( thePlayer, id, 120 ) end end) addEvent( "onBoughtBurger", true ) addEventHandler( "onBoughtBurger", getRootElement(), function(thePlayer,cash) setPlayerMoney(thePlayer,getPlayerMoney(thePlayer)-cash) setElementHealth(thePlayer,getElementHealth(thePlayer)+cash) if getElementHealth > 100 then setElementHealth(thePlayer,100) end end) --server function a () triggerClientEvent(source,"TriggerClient",getRootElement()) end addEventHandler ( "onPlayerLogin",getRootElement(),a ) Client: local x, y = guiGetScreenSize() SkinMusic = "data/music/SkinSelectMusic.mp3" SkinAnims = {"dnce_M_b","DAN_Left_A","DAN_Down_A","DAN_Loop_A"} StartSkin = 0 NewSkin = false --client addEvent("TriggerClient",true) function SelectSkin () setElementInterior ( getLocalPlayer(), 0, 0,0,0 ) setCameraMatrix( 2745.8266601563,-2231.1694335938,62.25520324707, 3999.9999499991,-2607.4000244141,16.1) skin = createPed ( StartSkin, 2749.7502441406,-2232.7170410156,61.727611541748,60 ) setPedAnimation( skin, "DANCING", SkinAnims[math.random(1,4)]) fadeCamera( true, 10) setTime(0,0) SkinSelectMusic = playSound(SkinMusic,true) bindKey("arrow_r","down",NextSkin) bindKey("arrow_l","down",LastSkin) bindKey(".","down",SpawnPlayer) addEventHandler("onClientRender",getRootElement(),AnnounceSkinJob) guiSetVisible(lnextskin,true) guiSetVisible(rnextskin,true) guiSetVisible(spawnskin,true) showCursor(true) showChat(false) showPlayerHudComponent ( "radar", false ) end addEventHandler("TriggerClient",root,SelectSkin) function SpawnPlayer() local r,g,b = math.random(0,255),math.random(0,255),math.random(0,255) triggerServerEvent ( "onClientWantsToSpawn", getLocalPlayer(), getLocalPlayer(),StartSkin,r,g,b) unbindKey("arrow_r","down",NextSkin) unbindKey("arrow_l","down",LastSkin) unbindKey("lshift","down",SpawnPlayer) setTime(12,0) stopSound(SkinSelectMusic) removeEventHandler("onClientRender",getRootElement(),AnnounceSkinJob) showCursor(false) showChat(true) showPlayerHudComponent ( "radar", true ) guiSetVisible(lnextskin,false) guiSetVisible(rnextskin,false) guiSetVisible(spawnskin,false) setElementData(getLocalPlayer(),"red",r) setElementData(getLocalPlayer(),"green",g) setElementData(getLocalPlayer(),"blue",b) end function NextSkin() if StartSkin == 312 then StartSkin = -1 elseif StartSkin == 2 then StartSkin = 8 end StartSkin = StartSkin + 1 setElementModel(skin,StartSkin) setPedAnimation( skin, "DANCING", SkinAnims[math.random(1,4)]) SkinJobTextColor() end function LastSkin() if StartSkin == 0 then StartSkin = 313 elseif StartSkin == 9 then StartSkin = 3 end StartSkin = StartSkin - 1 setElementModel(skin,StartSkin) setPedAnimation( skin, "DANCING", SkinAnims[math.random(1,4)]) SkinJobTextColor() end lnextskin = guiCreateButton(x-x/1.30,y/1.22,x/5,y/20,"<<<",false) guiSetProperty(lnextskin,"PushedTextColour","FFFFFF00") guiSetFont(lnextskin,"sa-header") rnextskin = guiCreateButton(x-x/2.90,y/1.22,x/5,y/20,">>>",false) guiSetProperty(rnextskin,"PushedTextColour","FFFFFF00") guiSetFont(rnextskin,"sa-header") spawnskin = guiCreateButton(x-x/1.80,y/1.22,x/5,y/20,"Play",false) guiSetProperty(spawnskin,"PushedTextColour","FFFFFF00") guiSetFont(spawnskin,"sa-header") guiSetVisible(lnextskin,false) guiSetVisible(rnextskin,false) guiSetVisible(spawnskin,false) addEventHandler( "onClientGUIClick", getRootElement(), function() if source == lnextskin then LastSkin() elseif source == rnextskin then NextSkin() elseif source == spawnskin then SpawnPlayer() end end) ------PEDS function FreezeBots() local Bots = getElementsByType("ped") for k,v in ipairs(Bots) do setElementFrozen(v,true) end end function loadMansion () outputChatBox("[bem-Vindo Ao Server]", getRootElement(), 255, 0, 0,true ) end addEventHandler("onClientResourceStart", getResourceRootElement(), loadMansion) There, it should work perfectly now. There are still some variables and elements that are missing in the client, like SkinSelectMusic and AnnounceSkinJob, but I assume those are in the other portion of the code.
  18. function fncClientPlayerDamage() if not (getElementInterior(source) == 0) then cancelEvent() end end addEventHandler("onClientPlayerDamage",getRootElement(),fncClientPlayerDamage() Add this to your client script. This will cancel out every damage done to a player inside an interior.
  19. The script appears to be working and I have not encountered any errors. Please specify what is the problem with it.
  20. ADCX

    RP Projekt!

    Trazim bilo koga tko je spreman na bilo koji nacin pomoci u izradnji Role Play servera. Ja sam trenutno jedini u timu (skripter). Ako je itko zaninteresiran (skripter, maper, dizajner...), nek me PM-a.
  21. <script src="script_client.lua" type="client"/> You forgot to close the tags.
  22. ADCX

    Not working.

    Looks like your SelectSkin function shows the skin selector. Trigger it at the point you want player to be able to choose skin, probably best to put it on "onClientResourceStart" event.
  23. ADCX

    getElementData<

    Well that additional setElementData that you added won't do anything since it already has to be true to even execute that part of the code. Element data is not predefined, think of it like a variable storage for element or object.
  24. ADCX

    Not working.

    Was there a skin selector before? Just remove or comment out the guiSetVisible functions that hide your skin selector elements.
  25. ADCX

    Not working.

    I've never 'reverse-engineered' it, but I'm pretty sure that it spawns the player when he joins, not when he logins. And the skin is set via the spawn function and not changed unless the player requests so with the F1 menu. So anyway he should be fine.
×
×
  • Create New...