public OnFilterScriptInit() { #define teszt return 1; } public OnFilterScriptExit() { #undef teszt return 1; }
#if defined teszt Msg(playerid, "Teszt"); #endif
What doesn't work, post the error if it appears or explain what's not working.
|
>Exit code: 0 Time: 8.609
Because you declared "teszt" as local define exclusively for OnFilterScriptInit().
|
public OnFilterScriptInit()
{
#define teszt
//here you defined it
return 1;
}
public OnFilterScriptExit()
{
//if you do a check here teszt is defined at this line
#undef teszt
// after this line you no longer can use teszt because there is no longer defined
return 1;
}
CMD:teszt(playerid, params[])
{
//this doesn't work because testz was undefined.
#if defined teszt
Msg(playerid, "Work");
#else
Msg(playerid, "Don't work");
#endif
return 1;
}
I think he should just put #define teszt on top of his script where all defines are.
I guess placing it under onfilterscriptinit only makes it work under onfilterscriptinit. So put it on top and remove #undef teszt |
#include <a_samp>
#include <plugin/streamer>
#include <plugin/sscanf2>
#define teszt
public OnFilterScriptInit()
{
printf(" FS loaded.");
return 1;
}
public OnFilterScriptExit()
{
printf(" FS unloaded.");
return 1;
}
CMD:teszt(playerid, params[])
{
#if defined teszt
Msg(playerid, "Work");
#else
Msg(playerid, "Don't work");
#endif
return 1;
}
#define FS_PROPERTY_NAME \
"MyTestProperty123"
public OnFilterScriptInit() {
if( existproperty(.name = FS_PROPERTY_NAME) ) {
print("property could not be created, it already exists!");
} else {
setproperty(.name = FS_PROPERTY_NAME);
if( existproperty(.name = FS_PROPERTY_NAME) ) {
print("property created successfully.");
} else {
print("property could not be created!");
}
}
}
public OnFilterScriptExit() {
if( existproperty(.name = FS_PROPERTY_NAME) ) {
deleteproperty(.name = FS_PROPERTY_NAME);
if( !existproperty(.name = FS_PROPERTY_NAME) ) {
print("property deleted");
} else {
print("property could not be deleted");
}
} else {
print("property does not exist");
}
print("property fs unloaded");
}
#define FS_PROPERTY_NAME \
"MyTestProperty123"
CMD:teszt(playerid, params[]) {
if( existproperty(.name = FS_PROPERTY_NAME) ) {
Msg(playerid, "Work");
} else {
Msg(playerid, "Don't work");
}
return 1;
}