Jump to content

Need help with my usersystem..


Vivalavido

Recommended Posts

Alright, I have created an usersystem wich works with MySql.

Now im having problems with adding a tag to a user as in: [ADMIN] User

Script:

function onJoin()
if( not connect_mysql ) then
	outputChatBox( "Could not connect to MySQL server [sqlnames]" )
else
	colour = mysql_query( connect_mysql, "SELECT class FROM clanusers WHERE serial='" .. getPlayerSerial( source ) .. "'" )
	if( colour ) then
		while true do
			local row = mysql_fetch_assoc(colour)
			if (not row) then break end
				if( row['name'] == "") then
					name = getPlayerName( source )
					class = "Guest"
				else
					name = row['name']
					class = row['class']
				end
			end
	end
	mysql_free_result( colour )
end
end
 
 
function onChat( message )
cancelEvent()
if( class == "Admin" ) then
	outputChatBox("#FF0000[Admin] " ..  getPlayerName(source) .. ': ' .. "#FFFFFF" .. message:gsub('#%x%x%x%x%x%x', ''), getRootElement(), 0, 0, 0, true)
elseif ( class == "Member" ) then
	outputChatBox("#7FFF00[MP] " ..  getPlayerName(source) .. ': ' .. "#FFFFFF" .. message:gsub('#%x%x%x%x%x%x', ''), getRootElement(), 0, 0, 0, true)
elseif( class == "Mod" ) then
	outputChatBox("#246119[Mod] " ..  getPlayerName(source) .. ': ' .. "#FFFFFF" .. message:gsub('#%x%x%x%x%x%x', ''), getRootElement(), 0, 0, 0, true)
elseif( class == "Mapper" ) then
	outputChatBox("#000000[Mapper] " ..  getPlayerName(source) .. ': ' .. "#FFFFFF" .. message:gsub('#%x%x%x%x%x%x', ''), getRootElement(), 0, 0, 0, true)
elseif( class == "Guest" ) then
	outputChatBox("#F96B09[Mod] " ..  getPlayerName (source) .. ': ' .. "#FFFFFF" .. message:gsub('#%x%x%x%x%x%x', ''), getRootElement(), 0, 0, 0, true)
end
end
addEventHandler ( "onPlayerJoin", getRootElement(), onJoin)
addEventHandler ( "onPlayerChat", getRootElement(), onChat )

It adds the tags, like a charm!

Problem is, im stated as Admin in the database. So it adds a [ADMIN] tag infront of my name.. That works fine..

Once another user joins, with the class Member, it adds the [MP] tags for everyone!

What would be best to make the function call only for the player that joines?

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.

×
×
  • Create New...