SA-MP Forums Archive
Roadblock - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Roadblock (/showthread.php?tid=430389)



Roadblock - NathNathii - 13.04.2013

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;
}



Re: Roadblock - Denying - 13.04.2013

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


Re: Roadblock - NathNathii - 13.04.2013

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;
}



Re: Roadblock - NathNathii - 13.04.2013

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


Re: Roadblock - Basssiiie - 13.04.2013

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.


Re: Roadblock - NathNathii - 13.04.2013

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


Btw thanks.


Re: Roadblock - JJB562 - 13.04.2013

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.


Re: Roadblock - NathNathii - 13.04.2013

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"



Re: Roadblock - JJB562 - 13.04.2013

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.


Re: Roadblock - NathNathii - 13.04.2013

Oh lol, no warnings now so gonna test it