-
Posts
525 -
Joined
-
Last visited
-
Days Won
3
Everything posted by justn
-
It doesn't have an error, i need help getting all the player's weapons he had before he died, and giving it back to him when he spawns again. function onWasted(totalAmmo, killer, killerWeapon, bodypart, stealth) if not( isGuestAccount (getPlayerAccount(source)) ) then local theWeapon = getPedWeapon (source) local weaponAmmo = getPedTotalAmmo (source) fadeCamera (source, false) setTimer (spawnPlayer, 1000, 1, source, 2036.1735839844, -1413.0563964844, 16.9921875, 0, getPedSkin (source), 0, 0, getPlayerTeam(source)) setTimer (setCameraTarget, 1250, 1, source, source) setTimer (fadeCamera, 2000, 1, source, true) end end addEventHandler ("onPlayerWasted", getRootElement(), onWasted)
-
so, when the player dies, i'd like it to get the weapons he had before he died, and return it back to him when he respawns. function onQuit () local account = getPlayerAccount(source) if account and not (isGuestAccount (account)) then local x,y,z = getElementPosition (source) setAccountData (account, "myCash", tostring (getPlayerMoney (source))) setAccountData (account, "posX", x) setAccountData (account, "posY", y) setAccountData (account, "posZ", z) setAccountData (account, "theSkin", tostring (getPedSkin (source))) setAccountData (account, "theInt", getElementInterior (source)) setAccountData (account, "theDim", getElementDimension (source)) setAccountData (account, "theWep0", getPedWeapon (source, 0)) setAccountData (account, "theWep1", getPedWeapon (source, 1)) setAccountData (account, "theWep2", getPedWeapon (source, 2)) setAccountData (account, "theWep3", getPedWeapon (source, 3)) setAccountData (account, "theWep4", getPedWeapon (source, 4)) setAccountData (account, "theWep5", getPedWeapon (source, 5)) setAccountData (account, "theWep6", getPedWeapon (source, 6)) setAccountData (account, "theWep7", getPedWeapon (source, 7)) setAccountData (account, "theWep8", getPedWeapon (source, -- s8) -->) setAccountData (account, "theWep9", getPedWeapon (source, 9)) setAccountData (account, "theWep10", getPedWeapon (source, 10)) setAccountData (account, "theWep11", getPedWeapon (source, 11)) setAccountData (account, "theWep12", getPedWeapon (source, 12)) setAccountData (account, "theAmmo0", getPedTotalAmmo (source, 0)) setAccountData (account, "theAmmo1", getPedTotalAmmo (source, 1)) setAccountData (account, "theAmmo2", getPedTotalAmmo (source, 2)) setAccountData (account, "theAmmo3", getPedTotalAmmo (source, 3)) setAccountData (account, "theAmmo4", getPedTotalAmmo (source, 4)) setAccountData (account, "theAmmo5", getPedTotalAmmo (source, 5)) setAccountData (account, "theAmmo6", getPedTotalAmmo (source, 6)) setAccountData (account, "theAmmo7", getPedTotalAmmo (source, 7)) setAccountData (account, "theAmmo8", getPedTotalAmmo (source, -- s8) -->) setAccountData (account, "theAmmo9", getPedTotalAmmo (source, 9)) setAccountData (account, "theAmmo10", getPedTotalAmmo (source, 10)) setAccountData (account, "theAmmo11", getPedTotalAmmo (source, 11)) setAccountData (account, "theAmmo12", getPedTotalAmmo (source, 12)) local team = getPlayerTeam(source) if (team) and not isGuestAccount(account) then setAccountData(account, "team", getTeamName(team)) end end end addEventHandler ("onPlayerQuit", getRootElement(), onQuit) function assigntheteam (old, acc) local acc = acc or getPlayerAccount(source) local firstTime = getAccountData(acc, 'firstTime') if not firstTime then setPlayerTeam(source, Unemployed) spawnPlayer(source, 1643.40002, -2249.10009, 13.300, 178.0004, 0, 0, 0, Unemployed) fadeCamera(source, true) setPlayerMoney ( source, 2000 ) setCameraTarget(source, source) setAccountData(acc, 'firstTime', 'true') else local playerMoney = getAccountData (acc, "myCash") local playerSkin = getAccountData (acc, "theSkin") local playerInt = getAccountData (acc, "theInt") local playerDim = getAccountData (acc, "theDim") local playerX = getAccountData (acc, "posX") local playerY = getAccountData (acc, "posY") local playerZ = getAccountData (acc, "posZ") local playerWeaponID0 = getAccountData (acc, "theWep0") local playerWeaponID1 = getAccountData (acc, "theWep1") local playerWeaponID2 = getAccountData (acc, "theWep2") local playerWeaponID3 = getAccountData (acc, "theWep3") local playerWeaponID4 = getAccountData (acc, "theWep4") local playerWeaponID5 = getAccountData (acc, "theWep5") local playerWeaponID6 = getAccountData (acc, "theWep6") local playerWeaponID7 = getAccountData (acc, "theWep7") local playerWeaponID8 = getAccountData (acc, "theWep8") local playerWeaponID9 = getAccountData (acc, "theWep9") local playerWeaponID10 = getAccountData (acc, "theWep10") local playerWeaponID11 = getAccountData (acc, "theWep11") local playerWeaponID12 = getAccountData (acc, "theWep12") local playerWeaponAmmo0 = getAccountData (acc, "theAmmo0") local playerWeaponAmmo1 = getAccountData (acc, "theAmmo1") local playerWeaponAmmo2 = getAccountData (acc, "theAmmo2") local playerWeaponAmmo3 = getAccountData (acc, "theAmmo3") local playerWeaponAmmo4 = getAccountData (acc, "theAmmo4") local playerWeaponAmmo5 = getAccountData (acc, "theAmmo5") local playerWeaponAmmo6 = getAccountData (acc, "theAmmo6") local playerWeaponAmmo7 = getAccountData (acc, "theAmmo7") local playerWeaponAmmo8 = getAccountData (acc, "theAmmo8") local playerWeaponAmmo9 = getAccountData (acc, "theAmmo9") local playerWeaponAmmo10 = getAccountData (acc, "theAmmo10") local playerWeaponAmmo11 = getAccountData (acc, "theAmmo11") local playerWeaponAmmo12 = getAccountData (acc, "theAmmo12") setPlayerMoney (source, tonumber(playerMoney)) spawnPlayer (source, playerX, playerY, playerZ +1, 0, playerSkin, 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) -- -- FOR TEAM local team = getAccountData (acc, "team") if (team) and getTeamFromName(team) then setPlayerTeam(source, getTeamFromName(team)) -- fadeCamera(source, true) setCameraTarget(source, source) end end end addEvent ( "IfNewPlayerJoin", true ) addEventHandler ( "IfNewPlayerJoin", getRootElement(), assigntheteam ) addEventHandler ("onPlayerLogin", getRootElement(), assigntheteam) function onWasted(totalAmmo, killer, killerWeapon, bodypart, stealth) if not( isGuestAccount (getPlayerAccount(source)) ) then local theWeapon = getPedWeapon (source) local weaponAmmo = getPedTotalAmmo (source) fadeCamera (source, false) setTimer (spawnPlayer, 1000, 1, source, 2036.1735839844, -1413.0563964844, 16.9921875, 0, getPedSkin (source), 0, 0, getPlayerTeam(source)) setTimer (setCameraTarget, 1250, 1, source, source) setTimer (fadeCamera, 2000, 1, source, true) end end addEventHandler ("onPlayerWasted", getRootElement(), onWasted)
-
Nice map ^^
-
Debugscript Errors: WARNING: Phone/phone_c.lua:20 Bad argument @ 'guiGetVisible' [Expected gui-element at argument 1, got boolean] WARNING: Phone/phone_c.lua:24 Bad argument @ 'guiSetVisible' [Expected gui-element at argument 1, got boolean] Phone_Image = guiCreateStaticImage(438, 112, 233, 398, ":guieditor/images/phone_s4.png", false) Anims = guiCreateStaticImage(21, 78, 44, 54, ":guieditor/images/apps/animations.png", false, Phone_Image) Banking = guiCreateStaticImage(22, 155, 43, 47, ":guieditor/images/apps/givecash.png", false, Phone_Image) Car_Mods = guiCreateStaticImage(96, 78, 42, 54, ":guieditor/images/apps/carmods.png", false, Phone_Image) Phone_Label = guiCreateLabel(75, 37, 86, 15, "*CIR* - Phone", false, Phone_Image) guiSetFont(Phone_Label, "default-bold-small") Map = guiCreateStaticImage(94, 155, 44, 47, ":guieditor/images/apps/map.png", false, Phone_Image) Events = guiCreateStaticImage(21, 228, 44, 50, ":guieditor/images/apps/events.png", false, Phone_Image) Sms = guiCreateStaticImage(94, 226, 42, 52, ":guieditor/images/apps/sms.png", false, Phone_Image) Gps = guiCreateStaticImage(21, 299, 44, 48, ":guieditor/images/apps/gps.png", false, Phone_Image) MW = guiCreateStaticImage(170, 78, 47, 54, ":guieditor/images/apps/mostwanted.png", false, Phone_Image) Music = guiCreateStaticImage(170, 155, 47, 47, ":guieditor/images/apps/music.png", false, Phone_Image) Notes = guiCreateStaticImage(170, 225, 47, 53, ":guieditor/images/apps/notes.png", false, Phone_Image) PhoneCall = guiCreateStaticImage(170, 299, 47, 48, ":guieditor/images/apps/phone.png", false, Phone_Image) Settings = guiCreateStaticImage(94, 299, 42, 48, ":guieditor/images/apps/settings.png", false, Phone_Image) bindKey ( "F2" , "down" , function () if guiGetVisible ( Phone_Image , true ) then guiSetVisible ( Phone_Image , false ) showCursor ( false ) else guiSetVisible ( Phone_Image , true ) showCursor ( true ) end end)
-
What exactly are you trying to say ?
-
Works, thanks ! I had to add the event "medic:healing" to the serverside since you forgot to add it.
-
E_e if anyone does not know how to fix this then nevermind i guess
-
function healPlayerOnHit_Handler(theAttacker, theWeapon, theBodyPart, theLoss) if(getElementType(theAttacker) == "player") then if isPlayerInTeam(theAttacker,"Medic") then if(theWeapon == 41) then cancelEvent() local targetCurrentHealth = getElementHealth ( source ) local newHealth = targetCurrentHealth+25 setElementHealth(source, newHealth) local randomCash = math.random ( 25, 50 ) givePlayerMoney(theAttacker,randomCash) end end end end end addEventHandler("onPlayerDamage", getRootElement(), healPlayerOnHit_Handler )
-
It doesn't works in clientside? What exactly doesn't work? and when you added the code then it worked but it stopped working? It worked and stopped working? How? the function healPlayerOnHit doesn't work in clientside, I have changed up the stuff like you told me and it doesn't work, and when i added this code to the function healPlayerOnHit, then the function stopped working properly if not targetCurrentHealth >= 100 then
-
The script does not work in clientside . So i tried it in serverside and it still does not work, Well, it works, but when I added the code if not targetCurrentHealth >= 100 then then it stopped working
-
._. Not everyone can be some 'experienced professional' at scripting, besides, I barely even script anyways, I usually play DM Racing and make maps
-
Problem fixed, but i need help with one more thing, if the other's player health is 100, i want theAttacker to stop getting money
-
Oops, sorry if i didnt mention the debugscript error. ERROR: Medic\server.lua:28: attempt to call global 'isPlayerInTeam' (a nil value)
-
Hi, i would like it if theAttacker is in team medic, then the other player's health will go up. function healPlayerOnHit_Handler(theAttacker, theWeapon, theBodyPart, theLoss) if(getElementType(theAttacker) == "player") then if isPlayerInTeam(theAttacker,"Medic") then if(theWeapon == 41) then cancelEvent() local targetCurrentHealth = getElementHealth(source) local newHealth = targetCurrentHealth+25 -- Replace 5 with the amount the player should be healed. setElementHealth(source, newHealth) local randomCash = math.random ( 25, 50 ) givePlayerMoney(theAttacker,randomCash) end end end end addEventHandler("onPlayerDamage", getRootElement(), healPlayerOnHit_Handler)
-
So this is a medic job im making, but, when the player gets 'theWeapon' and if he hits player i want it instead of the opposite player's health getting lower, it will get higher :3 server.lua function gotTheJob () setElementModel(source,275) setPlayerTeam(source, medic) theWeapon = giveWeapon ( source, 14 ) end addEvent("gotJob",true) addEventHandler ( "gotJob", getRootElement(), gotTheJob ) client.lua addEventHandler("onClientGUIClick",Medic_Window, function(b,thePlayer) if b == "left" then if source == Medic_GetJob then exports["TopBarChat"]:sendClientMessage("You are now a medic !",0, 125, 255, true) triggerServerEvent ( "gotJob", localPlayer) guiSetVisible(Medic_Window,false) guiSetVisible(Medic_GetJob,false) Medic_QuitJob = guiCreateButton(49, 228, 163, 36, "Quit Job", false, Medic_Window) showCursor(false) end end end)
-
Thanks. but i have one more problem, i added x,y,z,interior,dimension (also added skin) to save the player's position/skin when he leaves the server and joins back in, but the problem is, when i create new account and login, it works fine, but when i reconnect, it spawns me in the middle of the map. If anyone can help me it would be a pleasure, and actually, this is the only thing i need help with in the script function onQuit () local account = getPlayerAccount(source) if account and not (isGuestAccount (account)) then local x,y,z = getElementPosition (source) setAccountData (account, "firstTime", tostring (getPlayerMoney (source))) setAccountData (account, "firstTime", x) setAccountData (account, "firstTime", y) setAccountData (account, "firstTime", z) setAccountData (account, "firstTime", tostring (getPedSkin (source))) setAccountData (account, "firstTime", getElementInterior (source)) setAccountData (account, "firstTime", getElementDimension (source)) local team = getPlayerTeam(source) if (team) and not isGuestAccount(account) then setAccountData(account, "team", getTeamName(team)) end end end addEventHandler ("onPlayerQuit", getRootElement(), onQuit) function assigntheteam (old, acc) local acc = acc or getPlayerAccount(source) local firstTime = getAccountData(acc, 'firstTime') if not firstTime then setPlayerTeam(source, Unemployed) spawnPlayer(source, 1643.40002, -2249.10009, 13.300, 178.0004, 0, 0, 0, Unemployed) fadeCamera(source, true) setPlayerMoney ( source, 2000 ) setCameraTarget(source, source) setAccountData(acc, 'firstTime', 'true') else local playerMoney = getAccountData (acc, "firstTime") local playerSkin = getAccountData (acc, "firstTime") local playerInt = getAccountData (acc, "firstTime") local playerDim = getAccountData (acc, "firstTime") local playerX = getAccountData (acc, "firstTime") local playerY = getAccountData (acc, "firstTime") local playerZ = getAccountData (acc, "firstTime") setPlayerMoney (source, tonumber(playerMoney)) spawnPlayer (source, playerX, playerY, playerZ +1, 0, playerSkin, playerInt, playerDim) -- -- FOR TEAM local team = getAccountData (acc, "team") if (team) and getTeamFromName(team) then setPlayerTeam(source, getTeamFromName(team)) -- fadeCamera(source, true) setCameraTarget(source, source) end end end addEvent ( "IfNewPlayerJoin", true ) addEventHandler ( "IfNewPlayerJoin", getRootElement(), assigntheteam ) addEventHandler ("onPlayerLogin", getRootElement(), assigntheteam)
-
[DM] Gallardo - Vol.7 - Endless Possibilities - FREE DL
justn replied to Gallardo9944's topic in Showroom
Cool map ! Ty for the download. -
The output works, well there must be a problem in the setPlayerMoney
-
Nope No errors in debugscript.
-
Hi so. Unfortunately, the problem is on line 18, if the player has logged into the account for the first time. the money does not set to $2000. function onQuit (quitType, reason, responsibleElement) if not (isGuestAccount (getPlayerAccount (source))) then account = getPlayerAccount (source) if (account) then local x,y,z = getElementPosition (source) setAccountData (account, "firstTime", tostring (getPlayerMoney (source))) end end end addEventHandler ("onPlayerQuit", getRootElement(), onQuit) function assigntheteam (old, acc) local acc = getPlayerAccount(source) local firstTime = getAccountData(acc, 'firstTime') if (not firstTime) then setPlayerTeam(source, Unemployed) spawnPlayer(source, 1643.40002, -2249.10009, 13.300, 178.0004, 0, 0, 0, Unemployed) setPlayerMoney ( source, 2000 ) setAccountData(acc, 'firstTime', 'true') fadeCamera(source, true) setCameraTarget(source, source) else spawnPlayer(source, 1643.40002, -2249.10009, 13.300, 178.0004, 0, 0, 0) local playerMoney = getAccountData (acc, "firstTime") setPlayerMoney (source, playerMoney) fadeCamera(source, true) setCameraTarget(source, source) end end addEvent ( "IfNewPlayerJoin", true ) addEventHandler ( "IfNewPlayerJoin", getRootElement(), assigntheteam ) addEventHandler ("onPlayerLogin", getRootElement(), assigntheteam)
-
Thanks man ! Works great.