Jump to content

Script not working


xPawlo

Recommended Posts

Posted

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>

 

Posted (edited)

In console i didn't see any errors, it says that resource started succesfully

 

Edited by xPawlo
Posted (edited)

Yea right u need to check first weather script works In client or server side ! Always use debug script 1-3 mode to check errors console don't output errors for all functions 

Edited by Khadeer143
Posted

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)

 

Posted (edited)

Still not working. Console says "attempt to call global 'isPlayerInTeam' (a nil value)"

Edited by xPawlo
Posted

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

 

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...