No matching if; #endif
#1

I want to use this filter-script but I can't compile it... I get the error "no matching if" for #endif. I have tried a lot of things and evened used ****** to search for this error but haven't found it anywhere... Anyway, here's the code:

Код:
#include <a_samp>
#include <streamer>
#include <zcmd>

#define MAX_SNOW_OBJECTS    8
#define UPDATE_INTERVAL     750

#define ploop(%0)			for(new %0 = 0; %0 < MAX_PLAYERS; %0++) if(IsPlayerConnected(%0))
#define CB:%0(%1)           forward %0(%1); public %0(%1)

#define filterscript

new bool:snowOn[MAX_PLAYERS char],
	snowObject[MAX_PLAYERS][MAX_SNOW_OBJECTS],
	updateTimer[MAX_PLAYERS char]
;

public OnFilterScriptExit()
{
	ploop(i)
	{
	    if(snowOn{i})
	    {
	        for(new j = 0; j < MAX_SNOW_OBJECTS; j++) DestroyDynamicObject(snowObject[i][j]);
			KillTimer(updateTimer{i});
		}
	}
	return 1;
}

public OnPlayerDisconnect(playerid)
{
	if(snowOn{playerid})
	{
	    for(new i = 0; i < MAX_SNOW_OBJECTS; i++) DestroyDynamicObject(snowObject[playerid][i]);
		snowOn{playerid} = false;
		KillTimer(updateTimer{playerid});
	}
	return 1;
}

CB:UpdateSnow(playerid)
{
	if(!snowOn{playerid}) return 0;
	new Float:pPos[3];
	GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
	for(new i = 0; i < MAX_SNOW_OBJECTS; i++) SetDynamicObjectPos(snowObject[playerid][i], pPos[0] + random(25), pPos[1] + random(25), pPos[2] - 5 + random(10));
	return 1;
}

stock CreateSnow(playerid)
{
	if(snowOn{playerid}) return 0;
	new Float:pPos[3];
	GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
	for(new i = 0; i < MAX_SNOW_OBJECTS; i++) snowObject[playerid][i] = CreateDynamicObject(18864, pPos[0] + random(25), pPos[1] + random (25), pPos[2] - 5 + random(10), random(280), random(280), 0, -1, -1, playerid);
	snowOn{playerid} = true;
	updateTimer{playerid} = SetTimerEx("UpdateSnow", UPDATE_INTERVAL, true, "i", playerid);
	return 1;
}

stock DeleteSnow(playerid)
{
	if(!snowOn{playerid}) return 0;
	for(new i = 0; i < MAX_SNOW_OBJECTS; i++) DestroyDynamicObject(snowObject[playerid][i]);
	KillTimer(updateTimer{playerid});
	snowOn{playerid} = false;
	return 1;
}

CMD:snow(playerid, params[])
{
	if(snowOn{playerid})
	{
	    DeleteSnow(playerid);
	    SendClientMessage(playerid, 0x00FF00AA, "* It's not snowing anymore now.");
	}
	else
	{
	    CreateSnow(playerid);
	    SendClientMessage(playerid, 0x00FF00AA, "* Let it snow, let it snow, let it snow!");
	}
	return 1;
}

CMD:allsnowon(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return 0;
    ploop(i) //This is included in my FS! It's the '#define ploop(%0)' thing.
    {
        if(snowOn{i}) continue;
        CreateSnow(i);
    }
    return 1;
}

CMD:allsnowoff(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return 0;
    ploop(i)
    {
        if(!snowOn{i}) continue;
        DeleteSnow(i);
    }
    return 1;
}

#endif
Thx
Reply
#2

Remove the #endif
Reply
#3

That error shouldn't be occuring. Try to re-open pawno, and compile it. The #endif should be fine.
Reply
#4

He doesn't have it defining '#define FILTERSCRIPT' at the top of his filter-script.

Fixed Code:

Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>

#if defined FILTERSCRIPT

#include <a_samp>
#include <streamer>
#include <zcmd>

#define MAX_SNOW_OBJECTS    8
#define UPDATE_INTERVAL     750

#define ploop(%0)			for(new %0 = 0; %0 < MAX_PLAYERS; %0++) if(IsPlayerConnected(%0))
#define CB:%0(%1)           forward %0(%1); public %0(%1)

#define filterscript

new bool:snowOn[MAX_PLAYERS char],
	snowObject[MAX_PLAYERS][MAX_SNOW_OBJECTS],
	updateTimer[MAX_PLAYERS char]
;

public OnFilterScriptExit()
{
	ploop(i)
	{
	    if(snowOn{i})
	    {
	        for(new j = 0; j < MAX_SNOW_OBJECTS; j++) DestroyDynamicObject(snowObject[i][j]);
			KillTimer(updateTimer{i});
		}
	}
	return 1;
}

public OnPlayerDisconnect(playerid)
{
	if(snowOn{playerid})
	{
	    for(new i = 0; i < MAX_SNOW_OBJECTS; i++) DestroyDynamicObject(snowObject[playerid][i]);
		snowOn{playerid} = false;
		KillTimer(updateTimer{playerid});
	}
	return 1;
}

CB:UpdateSnow(playerid)
{
	if(!snowOn{playerid}) return 0;
	new Float:pPos[3];
	GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
	for(new i = 0; i < MAX_SNOW_OBJECTS; i++) SetDynamicObjectPos(snowObject[playerid][i], pPos[0] + random(25), pPos[1] + random(25), pPos[2] - 5 + random(10));
	return 1;
}

stock CreateSnow(playerid)
{
	if(snowOn{playerid}) return 0;
	new Float:pPos[3];
	GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
	for(new i = 0; i < MAX_SNOW_OBJECTS; i++) snowObject[playerid][i] = CreateDynamicObject(18864, pPos[0] + random(25), pPos[1] + random (25), pPos[2] - 5 + random(10), random(280), random(280), 0, -1, -1, playerid);
	snowOn{playerid} = true;
	updateTimer{playerid} = SetTimerEx("UpdateSnow", UPDATE_INTERVAL, true, "i", playerid);
	return 1;
}

stock DeleteSnow(playerid)
{
	if(!snowOn{playerid}) return 0;
	for(new i = 0; i < MAX_SNOW_OBJECTS; i++) DestroyDynamicObject(snowObject[playerid][i]);
	KillTimer(updateTimer{playerid});
	snowOn{playerid} = false;
	return 1;
}

CMD:snow(playerid, params[])
{
	if(snowOn{playerid})
	{
	    DeleteSnow(playerid);
	    SendClientMessage(playerid, 0x00FF00AA, "* It's not snowing anymore now.");
	}
	else
	{
	    CreateSnow(playerid);
	    SendClientMessage(playerid, 0x00FF00AA, "* Let it snow, let it snow, let it snow!");
	}
	return 1;
}

CMD:allsnowon(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return 0;
    ploop(i) //This is included in my FS! It's the '#define ploop(%0)' thing.
    {
        if(snowOn{i}) continue;
        CreateSnow(i);
    }
    return 1;
}

CMD:allsnowoff(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return 0;
    ploop(i)
    {
        if(!snowOn{i}) continue;
        DeleteSnow(i);
    }
    return 1;
}

#endif
Reply
#5

Quote:
Originally Posted by Akira297
Посмотреть сообщение
He doesn't have it defining '#define FILTERSCRIPT' at the top of his filter-script.

Fixed Code:

Код:
//#define FILTERSCRIPT

#include <a_samp>

#if defined FILTERSCRIPT


#endif
Yeah, that will just compile as an empty script. Think before posting. Contrary to popular belief, that line is not mandatory to compile a filterscript.
@OP: Do what gotwarzone said.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)