All pastes #159572 Raw Edit

Anonymous

public text v1 · immutable
·published 2006-09-03 06:44 UTC
rendered paste body
function eventPlayerSay( userid, strText, bTeam )
	        local len = string.len( _PlayerInfo( userid , "name" ) ) + 3;
        if bTeam then len = len + 7; end
        local message = string.sub( strText, len );
        
        if ( string.sub( message, 1, 11 ) == "/givehealth" ) then
                local player;
                local health;
                if not string.find( message, " ", 13 ) then
                        player = userid;
                        health = string.sub( message, 13 );
                else
                        player = string.sub( message, 13, string.find( message, " ", 13 ) - 1 );
                        health = string.sub( message, string.find( message, " ", 13 ) + 1 );
                end
                
                if ( health == "" ) then
                        _PrintMessage( userid, 3, "No health amount inputted." )
                        return;
                end
                
				local newhealth = _PlayerInfo( player, "health" ) + health;
				if ( newhealth <= 0 ) then
					_PlayerKill( player )
					_PrintMessage( userid, 4,  _PlayerInfo( player, "name" ) .. " has been killed!" )
					_PrintMessage( player, 4, "You have been killed." )
				else
					_PlayerSetHealth( player, _PlayerInfo( player, "health" ) + health )
					_PrintMessage( player, 4, "Your health has set to " .. newhealth .. "." )
				end
                return;
        end
        
        return strText;
end