Raised This Month: $32 Target: $400
 8% 

Setting invisibility amount [help]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 06-27-2015 , 21:14   Setting invisibility amount [help]
Reply With Quote #1

Setting invis/Alpha command on specific given userid

I't compiles, but gives a warning at line 34 "warning 213 mismatch" = Amount wont be set and alpha not working... how to fix this?

PHP Code:
#include <sourcemod>
#include <morecolors>          
#include <sdktools>

public OnPluginStart()
{
    
RegServerCmd("sm_xinvis"InvisRegister);
}

public 
Action:InvisRegister(args)
{
    new 
args_ GetCmdArgs();
    if (
args_ != 2)
    {
        
PrintToServer("Error: sm_xinvis <userid> <amount>");
        return 
Plugin_Handled;
    }
    new 
String:userid[32], String:amount[32];
    
GetCmdArg(1useridsizeof(userid));
    
GetCmdArg(2amountsizeof(amount));
    new 
client GetClientOfUserId(StringToInt(userid));
    new 
Float:i1_invis StringToFloat(amount);

    
Invis(clienti1_invis);

    return 
Plugin_Continue;
}

public 
Invis(clientFloat:Amount)
{
    if( 
client != && IsClientInGame(client) && IsPlayerAlive(client) )
    {
        
SetEntityRenderMode(clientRENDER_TRANSCOLOR);
        
SetEntityRenderColor(client255255255Amount);
    }

xines is offline
Kolapsicle
Senior Member
Join Date: Oct 2014
Old 06-27-2015 , 22:15   Re: Setting invisibility amount [help]
Reply With Quote #2

You are reading and setting the alpha channel as a float instead of an integer.
Kolapsicle is offline
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 06-27-2015 , 22:44   Re: Setting invisibility amount [help]
Reply With Quote #3

Ty, Kola works again. But!

I'm still getting a warning 213 tag mismatch at line 24, even tho the script now works lol?

Line 24 = Invis(client, i1_invis);

PHP Code:
    new client GetClientOfUserId(StringToInt(userid));
    new 
i1_invis StringToInt(amount);

    
Invis(clienti1_invis);

    return 
Plugin_Continue;
}

public 
Invis(clientint:Amount 
xines is offline
Kolapsicle
Senior Member
Join Date: Oct 2014
Old 06-28-2015 , 03:49   Re: Setting invisibility amount [help]
Reply With Quote #4

Remove "int:".

Invis(client, amount){}
Kolapsicle is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 06-28-2015 , 05:14   Re: Setting invisibility amount [help]
Reply With Quote #5

PHP Code:
#include <sourcemod>

public OnPluginStart()
{
    
RegConsoleCmd("sm_xinvis"Command_InvisRegister"Makes Client Invisible")
}

public 
Action:Command_InvisRegister(client1args)

    if (
args != 2)
    { 
        
PrintToConsole(client1"[SM] Usage : sm_xinvis <userid> <amount>"); 
        return 
Plugin_Handled
    }
    
    
decl String:userid[32];
    
decl String:amount[32]; 
    
    
GetCmdArg(1useridsizeof(userid)); 
    
GetCmdArg(2amountsizeof(amount)); 
    new 
client GetClientOfUserId(StringToInt(userid)); 
    new 
iInvisAmmount StringToInt(amount); 
    
    
Invis(clientiInvisAmmount); 
    
    return 
Plugin_Handled


Invis(clientiInvisAmmount

    if( 
client != && IsClientInGame(client) && IsPlayerAlive(client) ) 
    { 
        
SetEntityRenderMode(clientRENDER_TRANSCOLOR); 
        
SetEntityRenderColor(client255255255iInvisAmmount); 
    } 

This should work. Consider organizing yourself a little more as i1_invis makes no sense when it is a float.
headline is offline
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 06-28-2015 , 09:50   Re: Setting invisibility amount [help]
Reply With Quote #6

Quote:
Originally Posted by Headline22 View Post
[php]#include <sourcemod>

This should work. Consider organizing yourself a little more as i1_invis makes no sense when it is a float.
Yes thanks, both of you and kolapsicle.

- Yes i know the script ain't cleaned and fully organizied due to things are under developing, i all ready try to hold it pretty clear the way i'm coding, since i'm trying to get into the whole sourcemod scripting again.

Also i kept using "RegServerCmd" for a reason, so i had to change that again, also i dont get why u changed:

PHP Code:
    new String:userid[32], String:amount[32]; 
into only having:

PHP Code:
    decl String:userid[32]; 
    
decl String:amount[32]; 
could you explain to me why? Cheers
xines is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 06-28-2015 , 11:40   Re: Setting invisibility amount [help]
Reply With Quote #7

Quote:
Originally Posted by xines View Post
Yes thanks, both of you and kolapsicle.

- Yes i know the script ain't cleaned and fully organizied due to things are under developing, i all ready try to hold it pretty clear the way i'm coding, since i'm trying to get into the whole sourcemod scripting again.

Also i kept using "RegServerCmd" for a reason, so i had to change that again, also i dont get why u changed:

PHP Code:
    new String:userid[32], String:amount[32]; 
into only having:

PHP Code:
    decl String:userid[32]; 
    
decl String:amount[32]; 
could you explain to me why? Cheers
lol...headline, you do the same thing in your beacon plugin. The cvar you just added is g_bSomething [i forget the name], but it isnt a boolean,...tis an integer...not worth changing as you didnt actually declare it as a boolean, nor do you handle it as one, so it works fine. But i thought that it was funny you commenting to that.

Anyway, he changed the word new to decl to optimize your plugin a little. new sets aside the full size for the string (32) and initializes it, whereas decl only makes the variable (uninitialized), and only uses as much memory as is actually used to format your string. There's no need to move them to separate lines though.
__________________

Last edited by ThatOneGuy; 06-29-2015 at 01:52.
ThatOneGuy is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 06-28-2015 , 11:46   Re: Setting invisibility amount [help]
Reply With Quote #8

new initializes them to 0, decl doesn't
Miu is offline
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 06-28-2015 , 12:03   Re: Setting invisibility amount [help]
Reply With Quote #9

Getting quite confused about the "new, decl" thing, whenever to use new or decl, and about what sizes i need to use like [32] [128] and so on
xines is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 06-28-2015 , 12:45   Re: Setting invisibility amount [help]
Reply With Quote #10

Always use new, decl isn't even available in the new syntax. Sizes can be a bit harder, you have to think about how many characters you'll really need (and then generally add a few more), there are some defines to help you, such as PLATFORM_MAX_PATH for filepaths and a few others.
necavi is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:20.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode