Jump to content

[HELP]setskin function


DiGiTal

Recommended Posts

Hi, i've upload one skin for my premuim members, explaine;if he see as a premuim player, he will got the skin 150, if not all will get skin 200)


ERROR:



[13:53:37] Starting userpanel
[13:53:37] SCRIPT ERROR: userpanel\c_server.lua:2322: unexpected symbol near 'then'
[13:53:37] ERROR: Loading script failed: userpanel\c_server.lua:2322: unexpected symbol near 'then'
[13:53:39] userpanel restarted successfully


function skindonator(thePlayer)
if isGuestAccount(account) then return end
		if getAccountData(account,"donatorEnabled") == 1 then
		 	 setElementModel(thePlayer, 150 ) 			
                                          then
	      outputChatBox ("Enjoy your premuim skin")
		 else
                             setElementModel(thePlayer, 189 ) 
		
		end

end
addEventHandler("onPlayerLogin",getRootElement(),skindonator)

thx

Edited by Ridden
Link to comment
7 minutes ago, Ridden said:

@Deeze can you please explaine me why?

Sure thing!

"then" in LUA is only used in conjuction with an if-statement.

An if-statement works like this:

local apples = 5
if (apples == 5) then
  outputChatBox("I have 5 apples!")  
  outputChatBox("And i really love them!")
end

As you can see, we simply set a variable called 'apples' to the value of 5 and then, in our if statement, we simply check if the value of apples is equal to 5, and if it is, we execute the code between "then" and "end" (the two outputChatBox function calls). We do not need to write "then" between the two outputChatBox's because that is not how LUA syntax works.

You could check the MTA/LUA wiki for better explanation if my explanation wasn't clear enough :D

Edited by Deeze
  • Like 1
Link to comment
function skindonator(thePlayer)
	local account = getPlayerAccount (thePlayer)
		if isGuestAccount(account) then return end
			if getAccountData(account,"donatorEnabled") == 1 then
        		setElementModel(thePlayer, 150 ) 			
				outputChatBox ("Enjoy your premuim skin")
			else
        		 setElementModel(thePlayer, 189 )
			end
		end
end
addEventHandler("onPlayerLogin",getRootElement(),skindonator)

You forgot to define theplayer account

Edited by S3Nn4oX
  • Like 1
Link to comment
function skindonator(thePlayer)
	local account = getPlayerAccount (thePlayer)
		if isGuestAccount(account) then return end
			if getAccountData(account,"donatorEnabled") == 1 then
        		setElementModel(thePlayer, 150 ) 			
				outputChatBox ("Enjoy your premuim skin")
			else
        		 setElementModel(thePlayer, 189 )
			end
		end
addEventHandler("onPlayerLogin",getRootElement(),skindonator)

you have added one "end" :p, anyway thx for who posted .

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