Xierra Posted February 7, 2010 Share Posted February 7, 2010 All right, I wanted to start a new resource, called "Kill Chain" First, I want to make something like this: if player kill someone 2 times I don't know how to make that. Can you tell me an example a script like this: 1. Player kills someone < I don't have any idea how to do this 2. Player gets 1 score 3. Player kills someone the second time without dying. 4. Player gets 2 score and given a message (using xpeffects) and a sound (from utsounds): "Double kill!" and also in the chatbox: "Playername: Double Kill!" 5. Player was killed by someone < I know, onplayerwasted 6. Remove the streak and go back to zero kills < Don't know how 7. If player suicides, reduce score by one. < This one too After I did all of these I make more complex: 1. Player kills someone 2. Player gets 1 score 3. Player kills someone the second time without dying 4. Player gets 2 score and given a message (using xpeffects) and a sound (from utsounds): "Double kill!" and also in the chatbox: "Playername: Double Kill!" 5. Player shot someone at his head. 6. Player gets 2 score and given a message (using xpeffects) and a sound: "head shot!" 7. Player shot someone at his head the second time without dying (if player killed someone other than head, remove the heashot streak) 8. Player gets 3 score and given a message (using xpeffects) and a sound: "Double Head Shot!" and also in the chatbox: "playername: Double Head Shot!" Any help is appreciated and the resource will be publicly uploaded after I finished the resource. Maybe someone can answer how to do number 1-4 at the simpler ones? Link to comment
The_Ex Posted February 7, 2010 Share Posted February 7, 2010 onPlayerWasted has source (player who died) and argument (killer) so there shouldn't be any problems setting streaks/outputting messages or playing sounds for both of them. Just a little example: function checkKSandDS(ammon, attacker, weapon, bodypart) gCurrentKS[source] = 0 gCurrentDS[source] = gCurrentDS[source] + 1 if (attacker ~= false and attacker ~= source) then gCurrentKS[attacker] = gCurrentKS[attacker] + 1 gCurrentDS[attacker] = 0 end end addEventHandler("onPlayerWasted", getRootElement(), checkKSandDS) Link to comment
Xierra Posted February 26, 2010 Author Share Posted February 26, 2010 Before I close this topic, I'm trying to edit utsounds. It's using xpeffects Here's the edit: utsounds_server: local headshot = get("utsounds.EnableHeadshot") local sniper = get("utsounds.EnableSniper1Hit") local client = get("utsounds.AllowClientTurnOff") local special = get("utsounds.EnableSpecialKills") local ludicrousA = tonumber(get("utsounds.LudicrousAccuracy")) local monsterA = tonumber(get("utsounds.MonsterAccuracy")) local ultraA = tonumber(get("utsounds.UltraAccuracy")) local killreset = get("utsounds.ResetOnKill") local spawnreset = get("utsounds.ResetOnSpawn") local ludicrousB = tonumber(get("utsounds.LudicrousBullets")) local monsterB = tonumber(get("utsounds.MonsterBullets")) local ultraB = tonumber(get("utsounds.UltraBullets")) if headshot == "true" then headshot = true else headshot = false end if sniper == "true" then sniper = true else sniper = false end if client == "true" then client = true else client = false end if special == "true" then special = true else special = false end if killreset == "true" then killreset = true else killreset = false end if spawnreset == "true" then spawnreset = true else spawnreset = false end function resetAll() local players = getElementsByType("player") for i,player in ipairs (players) do setElementData(player,"killnumber",0) setElementData(player,"allbullets",0) setElementData(player,"allhits",0) setElementData(player,"accuracy",0) end end function resetStat(player,stat) setElementData(player,stat,0) end function checkBoth(angreifer,waffe,stelle) if headshot and stelle == 9 and waffe >= 22 then killPed(source,angreifer,waffe,stelle) elseif sniper and (stelle == 3 or stelle == 4 or stelle == 9) and waffe == 34 then killPed(source,angreifer,waffe,stelle) end end function headshotKillmessage(killer,waffe,stelle) if stelle == 9 then cancelEvent() local sourceTeam,killerTeam = getPlayerTeam(source),getPlayerTeam(killer) local rK,gK,bK = getPlayerNametagColor(killer) local rS,gS,bS = getPlayerNametagColor(source) exports.killmessages:outputMessage( {getPlayerName(killer),{"padding",width=3},{"icon",id=waffe},{"padding",width=3}, {"icon",id=256},{"padding",width=3},{"color",r=rS,g=gS,b=bS},getPlayerName(source)}, getRootElement(),rK,gK,bK) end end function checkKills(ammo,killer,weapon) if killer then if killer ~= source then local killerkills = getElementData(killer,"killnumber") if (not getPlayerTeam(source) or not getPlayerTeam(killer)) or getPlayerTeam(source) ~= getPlayerTeam(killer) then if killerkills == false then killerkills = 0 elseif killerkills == 2 then local sound = "multikill.mp3" addXPEffect ( "Multi Kill!", "2 Kills in a row", [ table color = { 255, 255, 255 } ] ) clearAll () triggerClientEvent(killer,"onSendSoundToClient",getRootElement(),sound) elseif killerkills == 3 then local sound = "triplekill.mp3" addXPEffect ( "Triple Kill!", "3 Kills in a row!", [ table color = { 255, 255, 255 } ] ) clearAll () triggerClientEvent(killer,"onSendSoundToClient",getRootElement(),sound) elseif killerkills == 4 then local sound = "killingspree.mp3" addXPEffect ( "Killing Spree!", "4 Kills in a row!", [ table color = { 0, 200, 0 } ] ) clearAll () triggerClientEvent(killer,"onSendSoundToClient",getRootElement(),sound) elseif killerkills == 6 then local sound = "dominating.mp3" addXPEffect ( "Dominating!", "6 Kills in a row!", [ table color = { 255, 255, 25 } ] ) clearAll () triggerClientEvent(killer,"onSendSoundToClient",getRootElement(),sound) elseif killerkills == 8 then local sound = "rampage.mp3" addXPEffect ( "Rampage!!", "8 Kills in a row!", [ table color = { 255, 0, 0 } ] ) clearAll () triggerClientEvent(killer,"onSendSoundToClient",getRootElement(),sound) elseif killerkills == 10 then local sound = "unstoppable.mp3" addXPEffect ( "Unstoppable!!", "10 Kills in a row!!", [ table color = { 0, 0, 150 } ] ) clearAll () triggerClientEvent(killer,"onSendSoundToClient",getRootElement(),sound) elseif killerkills == 12 then local sound = "holyshit.mp3" addXPEffect ( "Holy Sh*T!!", "You've got to be kidding me!? 12 Kills in a row!", [ table color = { 255, 0, 0 } ] ) clearAll () triggerClientEvent(killer,"onSendSoundToClient",getRootElement(),sound) elseif killerkills == 14 then local sound = "wickedsick.mp3" addXPEffect ( "Wicked Sick!!!", "I'm sick... 14 kills in a row!?", [ table color = { 0, 255, 0 } ] ) clearAll () triggerClientEvent(killer,"onSendSoundToClient",getRootElement(),sound) elseif killerkills == 16 then local sound = "godlike.mp3" addXPEffect ( "GOD Like!!!!", "You're a Pro! 16 Kills in a row!", [ table color = { 255, 0, 0 } ] ) clearAll () triggerClientEvent(killer,"onSendSoundToClient",getRootElement(),sound) end killerkills = killerkills + 1 setElementData(killer,"killnumber",killerkills) end end end end function returnTheSettings() local settings = { client, special, ludicrousA, monsterA, ultraA, killreset, spawnreset, ludicrousB, monsterB, ultraB } triggerClientEvent(source,"onSettingsReturn",getRootElement(),settings) end addEvent("onAskForServerSettings",true) addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),resetAll) addEventHandler("onPlayerDamage",getRootElement(),checkBoth) addEventHandler("onPlayerKillMessage",getRootElement(),headshotKillmessage) addEventHandler("onPlayerWasted",getRootElement(),checkKills) addEventHandler("onAskForServerSettings",getRootElement(),returnTheSettings) And the utsounds_client setElementData(getLocalPlayer(),"utToggle",true) local utvolume = 1 function killCheck(angreifer,waffe,stelle) if angreifer then if angreifer ~= source then local sourceteam,angreiferteam = getPlayerTeam(source),getPlayerTeam(angreifer) if angreifer == getLocalPlayer() then if sourceteam and angreiferteam and sourceteam == angreiferteam then playClientAudio("teamkiller.mp3") addXPEffect ( "Team Killer!", "Stop that! They're your friends!", [ table color = { 255, 255, 255 } ] ) clearAll () else if waffe >= 22 and waffe <= 34 then local killerkills = getElementData(angreifer,"killnumber") if not special and stelle == 9 then playClientAudio("headshot.mp3") addXPEffect ( "Headshot!", "Nice Shot!", [ table color = { 255, 0, 0 } ] ) clearAll () elseif not killerkills or killerkills % 2 == 1 or killerkills <= 1 or killerkills >= 18 then local ammocount = getElementData(source,"ammocount"..tostring(angreifer)) local accuracy = getElementData(angreifer,"accuracy") if ammocount and accuracy then if ammocount <= ludicrousB and accuracy >= ludicrousA then playClientAudio("ludicrouskill.mp3") addXPEffect ( "Ludicrous Kill!!", "hmm, impressive", [ table color = { 255, 0, 0 } ] ) clearAll () elseif ammocount <= monsterB and accuracy >= monsterA then playClientAudio("monsterkill.mp3") addXPEffect ( "Monster Kill!!", "Crazy! \"{SMILIES_PATH}/icon_wink.gif\" alt=\"\" title=\"Wink\" />", [ table color = { 255, 0, 0 } ] ) clearAll () elseif ammocount <= ultraB and accuracy >= ultraA then playClientAudio("ultrakill.mp3") addXPEffect ( "Ultra Kill!!", "Skillfull!", [ table color = { 255, 0, 0} ] ) clearAll () elseif stelle == 9 then playClientAudio("headshot.mp3") end end end end end elseif source == getLocalPlayer() and stelle == 9 and waffe >= 22 and waffe <= 34 then if not sourceteam or not angreiferteam or sourceteam ~= angreiferteam then --playClientAudio("blamiert.mp3") end end end setTimer(resetStat,50,1,source,"ammocount"..tostring(angreifer)) if killreset then setTimer(resetStat,50,1,angreifer,"allhits") setTimer(resetStat,50,1,angreifer,"allbullets") end end resetStat(source,"killnumber") if spawnreset then setTimer(resetStat,50,1,angreifer,"allhits") setTimer(resetStat,50,1,angreifer,"allbullets") end end function bulletCounting(waffe,ammo,magazinammo,,yd,zd,element) local allbullets = getElementData(source,"allbullets") if waffe >= 22 and waffe <= 34 then if not allbullets then allbullets = 1 else allbullets = allbullets + 1 end end local allhits = getElementData(source,"allhits") if not allhits then allhits = 0 end if element then if waffe >= 22 and waffe <= 34 then if getElementType(element) == "vehicle" or getElementType(element) == "ped" then allhits = allhits + 1 elseif getElementType(element) == "player" then allhits = allhits + 1 local bullets = getElementData(element,"ammocount"..tostring(source)) if not bullets or bullets == 0 then setElementData(element,"ammocount"..tostring(source),1,false) else bullets = bullets + 1 setElementData(element,"ammocount"..tostring(source),bullets,false) end end end end if not allhits or allhits == 0 then setElementData(source,"accuracy",0) else setElementData(source,"accuracy",allhits / allbullets,true) end setElementData(source,"allbullets",allbullets) setElementData(source,"allhits",allhits) end function playClientAudio(sound) if getElementData(getLocalPlayer(),"utToggle") then local sound = playSound("sounds/"..sound, false) setSoundVolume(sound,csvolume) end end function resetStat(player,stat) setElementData(player,stat,0,true) end function toggleSounds() if client then local state = getElementData(getLocalPlayer(),"utToggle") if state == true then state = "#00FF00On" else state = "#FF0000Off" end outputChatBox("CS kill sounds are now: "..state,255,255,255,true) setElementData(getLocalPlayer(),"utToggle",not getElementData(getLocalPlayer(),"utToggle")) else outputChatBox("It's not allowed to toggle the sounds on this server.") end end function soundVolume(command,volume) if client then volume = tonumber(volume) if volume >= 1 then volume = 1 end if volume <= 0 then volume = 0 end utvolume = volume else outputChatBox("Setting the sound volume is not allowed on this server.") end end function getServerSettings() triggerServerEvent("onAskForServerSettings",getLocalPlayer()) end function saveSettings(settings) client = settings[1] special = settings[2] ludicrousA = settings[3] monsterA = settings[4] ultraA = settings[5] killreset = settings[6] spawnreset = settings[7] ludicrousB = settings[8] monsterB = settings[9] ultraB = settings[10] end addEvent("onSendSoundToClient",true) addEvent("onSettingsReturn",true) addEventHandler("onClientPlayerWasted",getRootElement(),killCheck) addEventHandler("onClientPlayerWeaponFire",getLocalPlayer(),bulletCounting) addEventHandler("onSendSoundToClient",getRootElement(),playClientAudio) addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),getServerSettings) addEventHandler("onSettingsReturn",getRootElement(),saveSettings) addCommandHandler("cssounds",toggleSounds) addCommandHandler("csvolume",soundVolume) Any ideas? It said to me that there is unexpected symbol near "[" in utsounds_server, line 65. Can you tell me what's the problem? Link to comment
Gamesnert Posted February 26, 2010 Share Posted February 26, 2010 addXPEffect ( "Multi Kill!", "2 Kills in a row", [ table color = { 255, 255, 255 } ] ) ... addXPEffect ( "Triple Kill!", "3 Kills in a row!", [ table color = { 255, 255, 255 } ] ) [ table color = { 255, 255, 255 } ] is simply wrong. It seems like you copied it straight out of some documentation. The [ ] are put there to indicate you don't need to specify this parameter. "table" is there to show what kind of parameter should be there, and "= {255, 255, 255}" is there to indicate the default value if not specified. These things are meant to show the scripter how to use the function, and will break Lua scripts if simply typed/copied over. Basically, this means you should do it like this: addXPEffect ( "Multi Kill!", "2 Kills in a row", { 255, 255, 255 } ) ... addXPEffect ( "Triple Kill!", "3 Kills in a row!", { 255, 255, 255 } ) Or: addXPEffect ( "Multi Kill!", "2 Kills in a row" ) ... addXPEffect ( "Triple Kill!", "3 Kills in a row!" ) Link to comment
Xierra Posted February 26, 2010 Author Share Posted February 26, 2010 Oh! So the [table color = {255, 255, 255} ] is wrong isn't it? Why don't he write: "{255, 255, 255}"? Yeah, but still, I'm a total noob, just started a scripting adventure and i'm still level 1! Anyway, I can't try it without someone else. Is there somebody good enough to make a server then I join? E-Mail: [email protected] Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now