AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [ Solved ] Define created (https://forums.alliedmods.net/showthread.php?t=188586)

Aooka 06-28-2012 03:23

[ Solved ] Define created
 
Hello, i've a little problem with my define wich i was created.

Code:
#define give_weapons( %1 , %2 , %3 , %4 )   give_item( %1 , %2 )                                             cs_set_user_bpammo( %1 , %3 , %4 )

For doing this after in my code :

Code:
give_weapons( id , "weapon_m4a1" , CSW_M4A1 , 250 );

But it do not work. Why ?
Is it possible or not ?

Xalus 06-28-2012 06:28

Re: [ Request ] Define created
 
PHP Code:

stock give_weaponsplayer weaponname[] , weaponID bullets )
{     
     
give_itemplayer weaponname )
     
cs_set_user_bpammoplayer weaponID bullets )



Aooka 06-28-2012 06:31

Re: [ Request ] Define created
 
Oh thanks. So it's impossible to do that with ... define ?
It's work fine :)

lucas_7_94 06-28-2012 06:33

Re: [ Request ] Define created
 
You can't do that are you want to do in a simple 'define'.

You should create a stock or something ( i think ).

Arkshine 06-28-2012 06:34

Re: [ Request ] Define created
 
You can use a macro, but it should more defined like that :

Code:

#define give_weapons(%1,%2,%3,%4)  ( give_item( %1, %2 ), cs_set_user_bpammo( %1, %3, %4 ) )
Note you must not put space in the header.

Aooka 06-28-2012 06:43

Re: [ Request ] Define created
 
Okay Thanks Lucas and Arkshine.
So one more question before to close the thread.

What is the best the define or the stock ?

Edit: I do that :
Code:
#define last_strip(1%,2%)       ( strip_user_weapons( %1 ), strip_user_weapons( %2 ), give_item( %1 "weapon_knife" ), give_item( %2 "weapon_knife" ) )

But it's too long. Is it possible to make a define on different line ?

Backstabnoob 06-28-2012 07:12

Re: [ Request ] Define created
 
Situational.

Arkshine 06-28-2012 07:25

Re: [ Request ] Define created
 
You have to use '\' to put things on another line.
That's said, you don't have to define things for all. For a group of natives, more appropriate to use a function instead, because if such macro is used more than one time, it's going to be redundant and you will increase plugin size for nothing. Also, for readability/debug/practical reason, there is no point to use a macro here.

Aooka 06-28-2012 08:13

Re: [ Request ] Define created
 
Ok thanks a lot.

Solved

Aooka 06-28-2012 10:57

Re: [ Solved ] Define created
 
Just to say it do not work when i do with '\'. It's work only if i compil in local. Impossible to compile on-line.


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

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