Roadblock
#1

This command is supposed to remove all roadblocks a swat created but it only removes two?

pawn Код:
CMD:rrball(playerid, params[])
{
 if(GetPlayerTeam(playerid) != TEAM_SWAT)
 return SendClientMessage(playerid, -1, "{FF0000}Error: {FFFFFF}Only S.W.A.T may use this command!");
 for(new i = 0; i <= CreatedBlocks[i]; i++) DestroyObject(CreatedBlocks[i]);
 SendClientMessage(playerid, COLOR_LIGHTBLUE, "Roadblocks removed!");
 return 1;
}
Reply
#2

How do you check how many roadblocks were made, I mean.. show me roadblock create or whatever.
Reply
#3

Command to create
pawn Код:
CMD:rb(playerid, params[])
{
 if(GetPlayerTeam(playerid) != TEAM_SWAT)
 return SendClientMessage(playerid, -1, "{FF0000}Error: {FFFFFF}Only S.W.A.T may use this command!");
 new Float:X, Float:Y, Float:Z, Float:A;
 GetPlayerPos(playerid, X, Y, Z);
 GetPlayerFacingAngle(playerid, A);
 new block = CreateObject(978, X, Y, Z, 0.0, 0.0, A);
 CreatedBlocks[CreatedBlock] = block;
 CreatedBlock++;
 SendClientMessage(playerid, COLOR_LIGHTBLUE, "S.W.A.T Roadblock Placed!");
 return 1;
}
Reply
#4

Also found another thing.

When someone places a roadblock, and I type /rrball (I did not place any roadblocks), it removes the other guy's roadblocks o_O
Reply
#5

In your first script:
Код:
for(new i = 0; i <= CreatedBlocks[i]; i++) DestroyObject(CreatedBlocks[i]);
You might want to change that to this:
Код:
for(new i = 0; i < CreatedBlock; i++) DestroyObject(CreatedBlocks[i]);
For your other problem: if you only want to remove the roadblocks of a certain player, you need to save the owners as well. Now you're just dumping every roadblock into one huge list, and then removing them all by reading that same list.
Reply
#6

And how am I supposed to save the owners?
I'm new into this..


Btw thanks.
Reply
#7

I made you a little system that could help you. Here it is:

pawn Код:
#define MAX_ROADBLOCKS 20

enum Roadblocks
{
    rCreated,
    rOwner,
    rObject
}
new rInfo[MAX_ROADBLOCKS][Roadblocks];

CMD:rb(playerid, params[])
{
    if(GetPlayerTeam(playerid) != TEAM_SWAT) return SendClientMessage(playerid, -1, "{FF0000}Error: {FFFFFF}Only S.W.A.T may use this command!");
    new Float:X, Float:Y, Float:Z, Float:A;
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, A);
    for(new i = 0;i < sizeof(rInfo); i++)
    {
        if(rInfo[i][rCreated] == 0)
        {
            rInfo[i][rCreated] = 1;
            rInfo[i][rOwner] = playerid;
            rInfo[i][rObject] = CreateObject(978, X, Y, Z, 0.0, 0.0, A);
        }
    }
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "S.W.A.T Roadblock Placed!");
    return 1;
}

CMD:rrball(playerid, params[])
{
    if(GetPlayerTeam(playerid) != TEAM_SWAT) return SendClientMessage(playerid, -1, "{FF0000}Error: {FFFFFF}Only S.W.A.T may use this command!");
    for(new i = 0; i < sizeof(rInfo); i++)
    {
        if(rInfo[i][rCreated] == 1)
        {
            if(rInfo[i][rOwner] == playerid)
            {
                DestroyObject(rInfo[i][rObject]);
            }
        }
    }
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "Roadblocks removed!");
    return 1;
}
It's untested, but it should work.
Reply
#8

It gives me 2 warnings at a line that does not exist o.O

Код:
C:\Users\linda\Documents\LVCnR Testing\gamemodes\LVCnR.pwn(572) : warning 203: symbol is never used: "CreatedBlock"
C:\Users\linda\Documents\LVCnR Testing\gamemodes\LVCnR.pwn(572) : warning 203: symbol is never used: "CreatedBlocks"
Reply
#9

Quote:
Originally Posted by NathNathii
Посмотреть сообщение
It gives me 2 warnings at a line that does not exist o.O

Код:
C:\Users\linda\Documents\LVCnR Testing\gamemodes\LVCnR.pwn(572) : warning 203: symbol is never used: "CreatedBlock"
C:\Users\linda\Documents\LVCnR Testing\gamemodes\LVCnR.pwn(572) : warning 203: symbol is never used: "CreatedBlocks"
Did you use my code? If you did, then you won't need those variables.
Reply
#10

Oh lol, no warnings now so gonna test it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)