/rrb (remove road blocks)
#1

Код:
	if(strcmp(cmd, "/rrb", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			if(PlayerInfo[playerid][pFaction] != 255 && FactionInfo[PlayerInfo[playerid][pFaction]][fType] == 1)
             {
             if (PlayerInfo[playerid][pRank] < 3)
                {
			        SendClientMessage(playerid, COLOR_WHITE, "All Road Blocks destroyed..");
                    for(new o = 0; o < MAX_OBJECTS; o++)
                    {
						if (PlayerInfo[playerid][pRank] < 3)
						{
					        DestroyObject(RoadBlockObject[o]);
                            RoadBlocks = 0;
                        }
                        else
						{
					        DestroyObject(RoadBlockObjectFBI[o]);
                            RoadBlocksFBI = 0;
                        }
                    }
			    }
			    else
			    {
			        SendClientMessage(playerid, COLOR_GREY, " You rank is to low to set a Road Block !");
	                return 1;
			    }
			}
		}
		return 1;
	}

Can anyone tell me why this cmd says all blocks removed but the objects dont leave the map?
Reply
#2

Help if you can please
Reply
#3

It should be like this, but, RoadBlocksFBI will never destroy since the command is already for Rank 3.

pawn Код:
if(strcmp(cmd, "/rrb", true) == 0)
{
    if(!IsPlayerConnected(playerid)) return 0;

    if(PlayerInfo[playerid][pRank] < 3)
    {
        if(PlayerInfo[playerid][pFaction] != 255 && FactionInfo[PlayerInfo[playerid][pFaction]][fType] == 1)
        {
            for(new o = 0; o < MAX_OBJECTS; o++)
            {
                DestroyObject(RoadBlockObject[o]);
                RoadBlocks = 0;
            }
            SendClientMessage(playerid, COLOR_WHITE, "All Road Blocks destroyed..");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_GREY, "Your rank is too low to set a Road Block!");
    }
    return 1;
}
Reply
#4

PHP код:
if(!IsPlayerConnected(playerid)) return 0
This can be deleted as you need to be connected to execute a command anyway.

PHP код:
if(PlayerInfo[playerid][pRank] < 3
Shouldn't this be
PHP код:
if(PlayerInfo[playerid][pRank] >= 3
This would mean your rank needs to be at 3 or higher to execute this command.

PHP код:
SendClientMessage(playeridCOLOR_GREY"Your rank is too low to set a Road Block!"); 
The command is used to destroy roadblocks, but your message indicates that you would create a roadblock, it's confusing.

And it could be written like this:
PHP код:
if(strcmp(cmd"/rrb"true) == 0)
{
    if(
PlayerInfo[playerid][pRank] < 3) return SendClientMessage(playeridCOLOR_GREY"Your rank is too low to set a Road Block!");
    if(
PlayerInfo[playerid][pFaction] != 255 && FactionInfo[PlayerInfo[playerid][pFaction]][fType] == 1)
    {
        for(new 
0MAX_OBJECTSo++)
        {
            
DestroyObject(RoadBlockObject[o]);
            
RoadBlocks 0;
        }
        
SendClientMessage(playeridCOLOR_WHITE"All Road Blocks destroyed..");
    }
        
    return 
1;

Reply
#5

Quote:
Originally Posted by AmigaBlizzard
Посмотреть сообщение
PHP код:
if(!IsPlayerConnected(playerid)) return 0
This can be deleted as you need to be connected to execute a command anyway.

PHP код:
if(PlayerInfo[playerid][pRank] < 3
Shouldn't this be
PHP код:
if(PlayerInfo[playerid][pRank] >= 3
This would mean your rank needs to be at 3 or higher to execute this command.
1. It's for more safety, a play may lagg and disconnect before the command executes.

2. Oh, didn't noticed that it was < istead of >=.
Reply
#6

Thanks for the support guys but i changed that and it still dont destroy the blocks
Код:
		if(strcmp(cmd, "/rrb", true) == 0)
{
    if(PlayerInfo[playerid][pRank] > 3) return SendClientMessage(playerid, COLOR_GREY, "Your rank is too low to destroy a Road Block!");

    if(PlayerInfo[playerid][pFaction] != 255 && FactionInfo[PlayerInfo[playerid][pFaction]][fType] == 1)
    {
        for(new o = 0; o < MAX_OBJECTS; o++)
        {
            DestroyObject(RoadBlockObject[o]);
            RoadBlocks = 0;
        }
        SendClientMessage(playerid, COLOR_WHITE, "All Road Blocks destroyed..");
    }

    return 1;
}
This is what i have at the top of the script aswell

new RoadBlockObject[MAX_OBJECTS];
new RoadBlocks = 0;
new RoadBlockObjectFBI[MAX_OBJECTS];
new RoadBlocksFBI = 0;
Reply
#7

That is some real shoddy looking code and shows to me you just downloaded a script and don't know anything about it the very design of any system is it's greatest flaw.
Reply
#8

C'mon, dude, give the guy a chance. Yeah, he doesn't know the basics, but we all used to learn basics, aren't we?

CSLangdale, show us how do u create these road blocks.
Reply
#9

Код:
if(strcmp(cmd, "/rb1", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
            if(PlayerInfo[playerid][pFaction] != 255 && FactionInfo[PlayerInfo[playerid][pFaction]][fType] == 1)
            {
			    if (PlayerInfo[playerid][pRank] < 3)
             {
			        SendClientMessage(playerid, COLOR_WHITE, "You have placed a Road Block, /rblock to Remove All Road Blocks.");
                    new Float:X,Float:Y,Float:Z,Float:A;
		            GetPlayerPos(playerid, X, Y, Z);
		            GetPlayerFacingAngle(playerid,A);
		            if(PlayerInfo[playerid][pFaction] == 1)
					{
	                    RoadBlocks++;
	                    RoadBlockObject[RoadBlocks] = CreateObject(981, X, Y, Z, 0, 0, A);
	                }
	                else
	                {
	                    RoadBlocksFBI++;
	                    RoadBlockObjectFBI[RoadBlocksFBI] = CreateObject(981, X, Y, Z, 0, 0, A);
	                }
			    }
		    	else
			    {
			        SendClientMessage(playerid, COLOR_GREY, " You rank is to low to set a Road Block !");
	                return 1;
			    }
			}
		}
		return 1;
	}
        if(strcmp(cmd, "/rb2", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
            if(PlayerInfo[playerid][pFaction] != 255 && FactionInfo[PlayerInfo[playerid][pFaction]][fType] == 1)
            {
			    if (PlayerInfo[playerid][pRank] < 3)
             {
			        SendClientMessage(playerid, COLOR_WHITE, "You have placed a Road Block, /rblock to Remove All Road Blocks.");
                    new Float:X,Float:Y,Float:Z,Float:A;
		            GetPlayerPos(playerid, X, Y, Z);
		            GetPlayerFacingAngle(playerid,A);
		            if(PlayerInfo[playerid][pFaction] == 1)
					{
	                    RoadBlocks++;
	                    RoadBlockObject[RoadBlocks] = CreateObject(973, X, Y, Z, 0, 0, A);
	                }
	                else
	                {
	                    RoadBlocksFBI++;
	                    RoadBlockObjectFBI[RoadBlocksFBI] = CreateObject(973, X, Y, Z, 0, 0, A);
	                }
			    }
		    	else
			    {
			        SendClientMessage(playerid, COLOR_GREY, " You rank is to low to set a Road Block !");
	                return 1;
			    }
			}
		}
		return 1;
	}
 		if(strcmp(cmd, "/cone", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
            if(PlayerInfo[playerid][pFaction] != 255 && FactionInfo[PlayerInfo[playerid][pFaction]][fType] == 1)
            {
			    if (PlayerInfo[playerid][pRank] < 3)
             {
			        SendClientMessage(playerid, COLOR_WHITE, "You have placed a Road Block, /rblock to Remove All Road Blocks.");
                    new Float:X,Float:Y,Float:Z,Float:A;
		            GetPlayerPos(playerid, X, Y, Z);
		            GetPlayerFacingAngle(playerid,A);
		            if(PlayerInfo[playerid][pFaction] == 1)
					{
	                    RoadBlocks++;
	                    RoadBlockObject[RoadBlocks] = CreateObject(1238, X, Y, Z-0.7, 0, 0, A);
	                }
	                else
	                {
	                    RoadBlocksFBI++;
	                    RoadBlockObjectFBI[RoadBlocksFBI] = CreateObject(1238, X, Y, Z-0.7, 0, 0, A);
	                }
			    }
		    	else
			    {
			        SendClientMessage(playerid, COLOR_GREY, " You rank is to low to set a Road Block !");
	                return 1;
			    }
			}
		}
		return 1;
	}
Reply
#10

It was just the top one originally but i wanted to add a few more objects in and i got this from a different script it wasnt originally in this one plus yea i dont know the alot about scripting but i am trying to learn this and we all have to start somewere....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)