AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   cell parameters (https://forums.alliedmods.net/showthread.php?t=301562)

ghost95v 09-26-2017 05:32

cell parameters
 
Hello, i'm wondering how can i put the parameters for the "WriteShort(Float Fade time) and "WriteShort(Float Fade duration)" for the message "ScreenFade" in the code below


so the native in sma code would be -native send_screen_fade(Index, Float:Fade, Float: Duration, Type, Red, Green, Blue, Alpha)


PHP Code:

static cell AMX_NATIVE_CALL send_screen_fadeAMX *, cell pParameters ) {
    if( 
gpGlobals -> time && !FNullEntINT_TO_EDICTpParameters] ) ) ) {
        
MESSAGE_BEGINMSG_ONE_UNRELIABLECMessages.screenfade0ENTINT_TO_EDICTpParameters] ) ) );
        
WRITE_SHORT4096 ); // this parameter
        
WRITE_SHORT2048 ); // this parameter
        
WRITE_SHORT); // and this parameter
        
WRITE_BYTEpParameters] );
        
WRITE_BYTEpParameters] );
        
WRITE_BYTEpParameters] );
        
WRITE_BYTEpParameters] );
        
MESSAGE_END( );
    }

    return 
1;



so i would send the screen fade like:

PHP Code:

public func(index)
{
     
// for exapmle  
     
send_screen_fade(index1.00,600x000025500255// id, float fade, float duration, fade type , color red, green, blue, alpha





klippy 09-26-2017 06:40

Re: cell parameters
 
Do it just like you would do with any other parameter? Not sure what exactly is the issue here. If you want to get the float value from a parameter you can use amx_ctof function.

ghost95v 09-26-2017 07:13

Re: cell parameters
 
Yes, yes solved, i just puted like the other parametters

but i still cannot send the "ScreenFade" message with duration and fade time float

like :
Code:

send_screen_fade(index, 2.00, 0.40....)
i only can:
Code:

send_screen_fade(index, (1<<12), (1<<12), ...
or:
Code:

send_screen_fade(index, (1<<12)*2, (1<<12)*4, ...
PHP Code:

static cell AMX_NATIVE_CALL send_screen_fadeAMX *, cell pParameters ) {
    if( 
gpGlobals -> time && !FNullEntINT_TO_EDICTpParameters] ) ) ) {
        
MESSAGE_BEGINMSG_ONE_UNRELIABLECMessages.screenfade0ENTINT_TO_EDICTpParameters] ) ) );
        
WRITE_SHORTpParameters] ); 
        
WRITE_SHORTpParameters] ); 
        
WRITE_SHORTpParameters] ); 
        
WRITE_BYTEpParameters] );
        
WRITE_BYTEpParameters] );
        
WRITE_BYTEpParameters] );
        
WRITE_BYTEpParameters] );
        
MESSAGE_END( );
    }

    return 
1;



klippy 09-26-2017 07:26

Re: cell parameters
 
1 << 12 is equal to 4096. So you can multiply 4096 by the number of (floating point) seconds and then round it to the nearest short integer.

ghost95v 09-26-2017 07:50

Re: cell parameters
 
Thank you i appreciate your advice.

but how can i round it in cpp like this below writted in pawn

PHP Code:


stock do_screen_fade
(idFloat:fadeTimeFloat:holdTimetyperedgreenbluealpha)

    new 
fadehold;
    
fade clamp(    floatround(     fadeTime float(1<<12)), 00xFFFF    );

    
hold clamp(     floatround(         holdTime float(1<<12)), 00xFFFF      );
        
    
// Message
    
message_begin(    MSG_ONE_UNRELIABLE"ScreenFade"_id );
    
write_short(          fade    );
    
write_short(    hold    );
    
write_short(    type   );
    
write_byte(      red    );
    
write_byte(  green    );
    
write_byte(    blue    );
    
write_byte(     alpha    );
    
message_end(    ); 


klippy 09-26-2017 08:51

Re: cell parameters
 
Search on Google, that's been answered too many times already.


All times are GMT -4. The time now is 21:54.

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