AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Trying to write an include File... (https://forums.alliedmods.net/showthread.php?t=45355)

Silencer123 09-30-2006 11:24

Trying to write an include File...
 
First of all, I started with a simple Plugin like this (which has no Bugs):
Code:
#include <amxmodx> #include <amxmisc> #include <fun_shortcuts> #define VERSION "1.0" public plugin_init() {     register_plugin("Screen Flash",VERSION,"Silencer")     register_concmd("amx_flash","flash",ADMIN_BAN,"Playername Duration Holdtime Fadetype Red Green Blue Alpha - Flash a Player") } public flash(id,level,cid) {     if(!cmd_access(id,ADMIN_BAN,cid,9))     {         return PLUGIN_HANDLED     }         new arg[32]     read_argv(1,arg,31)     new target=cmd_target(1,arg,11)         if(!target)     {         return PLUGIN_HANDLED     }         new dp[16]     read_argv(2,dp,15)     new Float:d=str_to_float(dp)         new hp[16]     read_argv(3,hp,15)     new Float:h=str_to_float(hp)         new fp[16]     read_argv(4,fp,15)     new f=str_to_num(fp)         new rp[16]     read_argv(5,rp,15)     new r=str_to_num(rp)         new gp[16]     read_argv(6,gp,15)     new g=str_to_num(gp)         new bp[16]     read_argv(7,bp,15)     new b=str_to_num(bp)         new ap[16]     read_argv(8,ap,15)     new a=str_to_num(ap)         set_user_screen_flash(target,d,h,f,r,g,b,a)         return PLUGIN_HANDLED }
You see 'set_user_screen_flash(target,d,h,f,r,g,b,a)' , which does not exist.
So I made a new Include-File called 'fun_shortcuts.inc'. But when compiling I get this Error:
Start of Function Body without Function Header.
Please Help me! Here is the include File:
Code:
/* Fun Shortcuts by Silencer ** This file is provided as is (no warranties). */ #if !defined _fun_shortcuts_included     #define _shortcuts_included #if !defined _amxmodx_included     #include <amxmodx.inc> #endif /* Flash Screen */ native set_user_screen_flash(index = 0, Float:duration = 2.5, Float:holdtime = 0.5, fadetype = 0, red = 255, green = 255, blue = 255, alpha = 255); {     message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},index);     write_byte(duration);     write_byte(holdtime);     write_byte(fadetype);     write_byte(red);     write_byte(green);     write_byte(blue);     write_byte(alpha);     message_end(); }

schnitzelmaker 09-30-2006 12:12

Re: Trying to write an include File...
 
removed(outdated)

Silencer123 09-30-2006 12:42

Re: Trying to write an include File...
 
wth u make it to num again?
it works as float.
nvm stock just gives me more errors:
old style prototypes used with optional semicolons
start of function body without function header
Function 'set_user_screen_flash' is not implemented on line 58

schnitzelmaker 09-30-2006 12:48

Re: Trying to write an include File...
 
//removed

Silencer123 09-30-2006 19:11

Re: Trying to write an include File...
 
Okay fixed those.
but it still says that body/header thing.

XxAvalanchexX 10-01-2006 00:25

Re: Trying to write an include File...
 
Natives don't work like that. You have to use a stock.

Silencer123 10-01-2006 05:42

Re: Trying to write an include File...
 
Okay but there are still some problems.
Code:
/* Fun Shortcuts by Silencer ** This file is provided as is (no warranties). */ #if !defined _fun_shortcuts_included     #define _shortcuts_included #if !defined _amxmodx_included     #include <amxmodx.inc> #endif /* Flash Screen - Flags (FFADE_IN, FFADE_OUT, FFADE_MODULATE, FFADE_STAYOUT) */ stock set_user_screen_flash(index = 0, Float:duration = 2.5, Float:holdtime = 0.5, fadetype[] = "FFADE_OUT", red = 255, green = 255, blue = 255, alpha = 255) {     message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},index);     write_short(duration); // Tag mismatch (Also if using write_byte)     write_short(holdtime); // Tag mismatch (Also if using write_byte)     write_string(fadetype);     write_byte(red);     write_byte(green);     write_byte(blue);     write_byte(alpha);     message_end(); }

VEN 10-01-2006 06:25

Re: Trying to write an include File...
 
Quote:

#if !defined _fun_shortcuts_included
#define _shortcuts_included
#if !defined _amxmodx_included
#include <amxmodx.inc>
#endif
You missed #endif for the first #if

When passing duration and holdtime to the write_short they should be integer, not float.
Also you should note that you have to convert the seconds: http://forums.alliedmods.net/showthr...422#post255422

There are no write_string in ScreenFade message, it should be write_short

FFADE_IN, FFADE_OUT, FFADE_MODULATE, FFADE_STAYOUT shouldn't be strings, it is an HLSDK constants, but it's not in the default amxx includes so you have to copy them to your inc file.

Quote:

#define FFADE_IN 0x0000 // Just here so we don't pass 0 into the function
#define FFADE_OUT 0x0001 // Fade out (not in)
#define FFADE_MODULATE 0x0002 // Modulate (don't blend)
#define FFADE_STAYOUT 0x0004 // ignores the duration, stays faded out until new ScreenFade message received
Quote:

index = 0
I'd not recommend that because you are using MSG_ONE so the correct index should be passed, i.e. 0 shouldn't take place here. Or if you want you can do that:
Quote:

message_begin(!id ? MSG_ALL : MSG_ONE, ...)
This will allow to pass id == 0 which will mean that message will be sent to all players.

Silencer123 10-01-2006 07:15

Re: Trying to write an include File...
 
ok i understand it all just the "0x0000" part is confusing me.

VEN 10-01-2006 07:47

Re: Trying to write an include File...
 
0x0000 is 0 but since it's still a flag, you might want to pass more than one flag, for example 0 and (1<<1), but (0 | (1<<1)) is the same as (1<<0), so that's why 0x0000 is here: (0x0000 | (1<<1)), i.e. (0x0000 | 0x0002).


All times are GMT -4. The time now is 04:46.

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