Raised This Month: $ Target: $400
 0% 

Trying to write an include File...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Silencer123
Veteran Member
Join Date: Jul 2006
Old 09-30-2006 , 11:24   Trying to write an include File...
Reply With Quote #1

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(); }
__________________
EAT YOUR VEGGIES

Last edited by Silencer123; 09-30-2006 at 11:28.
Silencer123 is offline
schnitzelmaker
Senior Member
Join Date: Apr 2006
Location: HERE
Old 09-30-2006 , 12:12   Re: Trying to write an include File...
Reply With Quote #2

removed(outdated)
__________________

Last edited by schnitzelmaker; 10-02-2006 at 07:56.
schnitzelmaker is offline
Silencer123
Veteran Member
Join Date: Jul 2006
Old 09-30-2006 , 12:42   Re: Trying to write an include File...
Reply With Quote #3

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
__________________
EAT YOUR VEGGIES
Silencer123 is offline
schnitzelmaker
Senior Member
Join Date: Apr 2006
Location: HERE
Old 09-30-2006 , 12:48   Re: Trying to write an include File...
Reply With Quote #4

//removed
__________________

Last edited by schnitzelmaker; 10-02-2006 at 07:54.
schnitzelmaker is offline
Silencer123
Veteran Member
Join Date: Jul 2006
Old 09-30-2006 , 19:11   Re: Trying to write an include File...
Reply With Quote #5

Okay fixed those.
but it still says that body/header thing.
__________________
EAT YOUR VEGGIES
Silencer123 is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-01-2006 , 00:25   Re: Trying to write an include File...
Reply With Quote #6

Natives don't work like that. You have to use a stock.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Silencer123
Veteran Member
Join Date: Jul 2006
Old 10-01-2006 , 05:42   Re: Trying to write an include File...
Reply With Quote #7

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(); }
__________________
EAT YOUR VEGGIES

Last edited by Silencer123; 10-01-2006 at 05:47.
Silencer123 is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 10-01-2006 , 06:25   Re: Trying to write an include File...
Reply With Quote #8

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.

Last edited by VEN; 10-02-2006 at 06:29.
VEN is offline
Silencer123
Veteran Member
Join Date: Jul 2006
Old 10-01-2006 , 07:15   Re: Trying to write an include File...
Reply With Quote #9

ok i understand it all just the "0x0000" part is confusing me.
__________________
EAT YOUR VEGGIES
Silencer123 is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 10-01-2006 , 07:47   Re: Trying to write an include File...
Reply With Quote #10

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).
VEN is offline
Reply



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 04:46.


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