Removing roadblocks.
#1

I've made a filterscript for roadblocks, and it's working fine with CMD:rc (Which is remove cone), and CMD:cone [1-6](Which places it), but after some bug testing i see that if someone breaks the roadblock, you wont be able to find where the roadblock is located to go to it and /rc, which will cause the script to reach the max roadblocks and not allow any more until a server restart/FS reload. So i tried making a /rac (Remove all cones) command, and i try it in game, and it only removes a single cone. I may be missing something simple or just be dumb right now, but could someone help me out? It's 2am, which is probably why i'm messing up on this command.

This is what i've got. It compile with no warnings, and everything works in game, it simply just removes one cone instead of all of them.

My stock:
Код:
stock RemoveAllRoadblock(playerid)
{
	for(new i = 0; i < sizeof(Roadblock); i++)
	{
		if(Roadblock[i][rCreated] == 1)
		{
    	    Roadblock[i][rCreated] = 0;
    	    Roadblock[i][rX] = 0.0;
    	    Roadblock[i][rY] = 0.0;
    	    Roadblock[i][rZ] = 0.0;
    	    DestroyDynamicObject(Roadblock[i][rObject]);
    	    return 1;
    	}
    	else
    	{
    		SendClientMessage(playerid, COLOR_LIGHTRED, "There isn't a road block to remove!");
    	}
    	return 1;
	}
	return 1;
}
My command:
Код:
CMD:rac(playerid) return cmd_removeallcones(playerid);
CMD:removeallcones(playerid)
{
	if (IsPlayerConnected(playerid))
	{
		RemoveAllRoadblock(playerid);
  		SendClientMessage(playerid, COLOR_LIGHTBLUE, "   You have removed aa the roadblocks!");
	}
	else
	{
		SendClientMessage(playerid, COLOR_LIGHTRED, "	You can't do this right now!");
	}
	return 1;
}
Edit: I just noticed in the code above it's showing i have loose indentations, this is not the issue as I checked my .pwn after seeing this and there are infact no loose indentations in the script.
Reply
#2

pawn Код:
DestroyDynamicObject(Roadblock[i][rObject]);
            return 1;
If you were no so return happy this wouldn't happen

pawn Код:
stock RemoveAllRoadblock(playerid)
{
    new blocksremoved;
    for(new i = 0; i < sizeof(Roadblock); i++)
    {
        if(Roadblock[i][rCreated] == 1)
        {
            Roadblock[i][rCreated] = 0;
            Roadblock[i][rX] = 0.0;
            Roadblock[i][rY] = 0.0;
            Roadblock[i][rZ] = 0.0;
            DestroyDynamicObject(Roadblock[i][rObject]);
            blocksremoved++;
        }
    }
    if(blocksremoved)
    {
        new line[128];
        format(line, sizeof(line), "Removed %i roadblocks", blocksremoved);
        SendClientMessage(playerid, COLOR_LIGHTRED, line);
    }
    else SendClientMessage(playerid, COLOR_LIGHTRED, "No road blocks were removed!");
   
    return 1;
}
Reply
#3

How silly of me, thank's for the help! Note to self: No more scripting while sleepy.
Just for making me be able to go to sleep sooner, i'l give you a +rep :P
I've got class in 3 hours.. I've been scratching my head for a good 30 minutes about this and i have no clue why i didn't figure it out.

Here's the finished product Minus the remove command ofc ;P
With a small taste of my SD mapping(Still unfinished)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)