xPawlo

Script not working

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>

 

Share this post


Link to post

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

 

Edited by xPawlo

Share this post


Link to post

setPedArmor is server side only, you can't use it client side.

Share this post


Link to post

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

Share this post


Link to post

When I change to server side, the console says "attempt to call global 'getLocalPlayer' (a nil value)".

Share this post


Link to post

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)

 

Share this post


Link to post

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

Edited by xPawlo

Share this post


Link to post

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

 

Share this post


Link to post

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.