Jump to content

Script not working


xPawlo

Recommended Posts

Why this is not working? 

function poliwasted()
local player = getLocalPlayer()
local team = getTeamFromName("Milicja") 
    if isPlayerInTeam(player, team) then
	setElementModel ( player, 281 )
	setPedArmor ( player, 100 )
    setPlayerNametagColor ( player, 0, 8, 255 )
	giveWeapon( player, 3, 1000 )
   end
end
addEventHandler("onPlayerWasted", getRootElement(), poliwasted)
<meta>
     <info author="xPawlo" version="0.1" type="script" name="frakcje" description="" />
     <script src="frakcjeclient.lua" type="client" />
</meta>

 

Link to comment

yes because the getLocalPlayer is client side only

function poliwasted()
    local team = getTeamFromName("Milicja")
	if isPlayerInTeam(source, team) then
	   setElementModel(source, 281)
	   setPedArmor(source, 100)
	   setPlayerNametagColor(source, 0, 8, 255)
	   giveWeapon(source, 3, 1000)
	end
end
addEventHandler("onPlayerWasted", root, poliwasted)

 

Link to comment

Add the useful function in your code then.

function isPlayerInTeam(player, team)
    assert(isElement(player) and getElementType(player) == "player", "Bad argument 1 @ isPlayerInTeam [player expected, got " .. tostring(player) .. "]")
    assert((not team) or type(team) == "string" or (isElement(team) and getElementType(team) == "team"), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got " .. tostring(team) .. "]")
    return getPlayerTeam(player) == (type(team) == "string" and getTeamFromName(team) or (type(team) == "userdata" and team or (getPlayerTeam(player) or true)))
end

 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...