xDrul Posted October 8, 2013 Share Posted October 8, 2013 Hi, I'm tryin' to script a 'weapon kicker', a script which allow me to kick players to another position by shooting him/her.. Great to get rid of dm'ers at roleplays / admin events etc etc . I've tied to script it several times but failed alot which codes should i use? onClientDamage/setElementPosition?? All help much 'preciated! Link to comment
Castillo Posted October 8, 2013 Share Posted October 8, 2013 You could try: onClientPlayerWeaponFire with: setElementVelocity or setElementPosition Link to comment
WASSIm. Posted October 8, 2013 Share Posted October 8, 2013 (edited) onClientPlayerWeaponFire and triggerServerEvent kickPlayer Edited October 8, 2013 by Guest Link to comment
xDrul Posted October 8, 2013 Author Share Posted October 8, 2013 Yeah, i've tried that. It didnt work bcz i still don't know how to use that f8*]>|>|[cking code Link to comment
xDrul Posted October 8, 2013 Author Share Posted October 8, 2013 onClientPlayerWeaponFireand triggerServerEvent kickPlayer Doesnt kickPlayer kick the player out of the server? I actually ment the way to set their position to f.e. Las Vent. Cross. (so with setElementPosition(source, x, y, z, attacker) or idk Link to comment
WASSIm. Posted October 8, 2013 Share Posted October 8, 2013 you mean if admin shot to player will chane other position ? Link to comment
xDrul Posted October 8, 2013 Author Share Posted October 8, 2013 you mean if admin shot to player will chane other position ? Yeah, so i understand i should use getPlayerTeam & local team == ? And yep, so f.e. i shoot a bud with a M4 (or any other weapon(s), he will be 'kicked' warped to another position with setElementPosition) Link to comment
WASSIm. Posted October 8, 2013 Share Posted October 8, 2013 change posX, posY, posZ to you'r Position you want addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), function (weapon, _, _, _, _, _, hitElement ) if (getPlayerTeam ( localPlayer ) and getTeamName ( getPlayerTeam ( localPlayer ) ) == "Staff") then if weapon == 31 and hitElement and getElementType(hitElement)=="player" then setElementPosition ( hitElement, posX, posY, posZ ) end end end ) Link to comment
xDrul Posted October 8, 2013 Author Share Posted October 8, 2013 change posX, posY, posZ to you'r Position you want addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), function (weapon, _, _, _, _, _, hitElement ) if (getPlayerTeam ( localPlayer ) and getTeamName ( getPlayerTeam ( localPlayer ) ) == "Staff") then if weapon == 31 and hitElement and getElementType(hitElement)=="player" then setElementPosition ( hitElement, posX, posY, posZ ) end end end ) This one doesnt work o.0 Link to comment
myonlake Posted October 9, 2013 Share Posted October 9, 2013 Switch the getLocalPlayer in the event handler to "root". Link to comment
myonlake Posted October 9, 2013 Share Posted October 9, 2013 Either you're not using the code client-side or you didn't use M4 when testing. I removed the weapon ID so you can shoot them with any weapon. Client-side local posX, posY, posZ = 0, 0, 3 addEventHandler("onClientPlayerWeaponFire", root, function(weapon, _, _, _, _, _, hitElement) if (getPlayerTeam(localPlayer) and getTeamName(getPlayerTeam(localPlayer)) == "Staff") then if (hitElement) and (getElementType(hitElement) == "player") then setElementPosition(hitElement, posX, posY, posZ) end end end ) Link to comment
-.Paradox.- Posted October 9, 2013 Share Posted October 9, 2013 @xDRul you must be in staff team first, myonlake code is working all what you have to do is changing the coordinates to the ones you want to you use. Link to comment
xDrul Posted October 9, 2013 Author Share Posted October 9, 2013 StevyDK said: @xDRul you must be in staff team first, myonlake code is working all what you have to do is changing the coordinates to the ones you want to you use. Orly . I did, didn't work tho Link to comment
myonlake Posted October 9, 2013 Share Posted October 9, 2013 (edited) This actually makes no sense. It should work. I have debugged it as far as I can and setting team and fetching team works server-side, but doesn't work on client-side. I guess this is a bug then, I'll report to Mantis unless I can find the reason. Also, I made the synchronization work, the hit element should be moved away properly for all players now (not sure if it was the issue before, but just to make sure. Here's a small workaround. Client-side addEventHandler("onClientPlayerWeaponFire", root, function(weapon, _, _, _, _, _, hitElement) if (getElementData(localPlayer, "players.team")) and (getElementData(localPlayer, "players.team") == "Staff") then if (hitElement) and (getElementType(hitElement) == "player") then triggerServerEvent("sendPlayerAway", hitElement) end end end ) Server-side addEventHandler("onResourceStart", resourceRoot, function() for _,player in ipairs(getPlayersInTeam(getTeamFromName("Staff"))) do setElementData(player, "players.team", "Staff", true) end end ) local posX, posY, posZ = 0, 0, 3 addEvent("sendPlayerAway", true) addEventHandler("sendPlayerAway", root, function() setElementPosition(source, posX, posY, posZ) end ) Edited October 9, 2013 by Guest Link to comment
xDrul Posted October 9, 2013 Author Share Posted October 9, 2013 Thanks alot! It worked! Just one small question left, can i also add smthg like outputChatBox('player who've been kicked' has been kicked by 'the attacker'") ? Link to comment
xDrul Posted October 9, 2013 Author Share Posted October 9, 2013 Tfoe, i've tested it out with some friends.. They're able to kick me too (not in the Staff team) anyway to fix that? Besides that it works! Link to comment
myonlake Posted October 9, 2013 Share Posted October 9, 2013 That shouldn't be even possible, because if they're not in the Staff team, they wouldn't have the element data neither. Link to comment
xDrul Posted October 9, 2013 Author Share Posted October 9, 2013 Try it m8, i've copied & past exactly the same you posted Link to comment
myonlake Posted October 9, 2013 Share Posted October 9, 2013 xDrul said: Try it m8, i've copied & past exactly the same you posted I was more referring to the fact that everybody on your server are set to the admin team for a reason or another. Link to comment
xDrul Posted October 9, 2013 Author Share Posted October 9, 2013 o.0 anyway to fix it ? 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