Vice City Multiplayer

VC:MP 0.3 => mIRC/pawn Scripting => Topic started by: Fuzzy168 on November 13, 2011, 08:32:17 am

Title: includes?
Post by: Fuzzy168 on November 13, 2011, 08:32:17 am
How do i create Includes???
Title: Re: includes?
Post by: Skirmant on November 13, 2011, 12:36:53 pm
Here's how to write a C style include. Create a file named test.h inside include folder. Add this code inside the file:
 
Code: [Select]
#if defined Test_H // Checks if the Test_H macro is defined
#endif // Ends if the file was attempted of being included twice

#define Test_H // Defines the Test_H macro

public TestFunc() {
printf("TestFunct has been found o:");
}

Inside the main code add:

Code: [Select]
#include <test.h>
Now try calling the function and see how it goes. Cheers :P
Title: Re: includes?
Post by: stormeus on November 13, 2011, 12:53:40 pm
Slight correction:
[pawn]
#if defined Test_H // Checks if the Test_H macro is defined
#endif // Ends if the file was attempted of being included twice
[/pawn]

Should be
[pawn]
#if defined Test_H // Checks if the Test_H macro is defined
    #endinput // Stop if the file was included before
#endif
[/pawn]

Everything else looks good.
Title: Re: includes?
Post by: Skirmant on November 13, 2011, 01:13:01 pm
Ups. Forgot that pawn uses slightly different rules of macrology ???
Title: Re: includes?
Post by: Fuzzy168 on November 13, 2011, 02:05:15 pm
If i create an include name test.inc its still the same right?
Title: Re: includes?
Post by: Skirmant on November 13, 2011, 02:18:56 pm
If i create an include name test.inc its still the same right?

Yup. But when loading .inc files use:
[pawn]#include <test>[/pawn]
Title: Re: includes?
Post by: Fuzzy168 on November 15, 2011, 01:19:14 pm
Ok thanks...