SA-MP Forums Archive
error 003 - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: error 003 (/showthread.php?tid=166951)



error 003 - Ritchie999 - 10.08.2010

I get this error
Код:
(87) : error 003: declaration of a local variable must appear in a compound block
From this line here

pawn Код:
new bomb - IsValidObject(1252);
Here is the full snippet
pawn Код:
if(!strcmp(cmdtext,"/detonateC4",true))

    {
        if(C4Placed[playerid] == 0)


        {
            SendClientMessage(playerid, COLOR_RED,"You Haven't placed C4");


        }
        if(C4Placed[playerid] != 0)
        new bomb - IsValidObject(1252);
        new Float:bx,Float:by,Float:bz;
        GetObjectPos(bomb,bx,by,bz);
        CreateExplosion(bx,by,bz+1,7,10);
        DestroyObject(bomb);
        C4Placed[playerid =0];
        return 1;

    }
Any idea how to sort this?


Re: error 003 - Vince - 10.08.2010

Uh?
What are you trying to do?


Re: error 003 - JaTochNietDan - 10.08.2010

pawn Код:
new bomb = 1252;
No need for the valid object check, since you know it's valid because you've obviously checked the ID to make sure it was right


Re: error 003 - Ritchie999 - 11.08.2010

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
pawn Код:
new bomb = 1252;
No need for the valid object check, since you know it's valid because you've obviously checked the ID to make sure it was right
Still get the same error on same line


Re: error 003 - willsuckformoney - 11.08.2010

i has this that works

pawn Код:
//at top
new C4Placed[MAX_PLAYERS] = 0;
new HasC4[MAX_PLAYERS] = 0;
new Bomb[MAX_PLAYERS];
new bombs;
forward boom(objectid, playerid);

//OnPlayerConnect
C4Placed[playerid] =0;
    HasC4[playerid] =0;

//OnPlayerSpawn
C4Placed[playerid] =0;
    HasC4[playerid] =0;

////OnPlayerCommandText
if(strcmp(cmdtext, "/buybomb", true) == 0)
    {
        if(GetPlayerMoney(playerid) > 14999)
        {
            if(HasC4[playerid] == 0)
            {
                HasC4[playerid] =1;
                GivePlayerMoney(playerid, -15000);
                SendClientMessage(playerid,lime,"You can plant the bomb with /plantbomb (/pb)");
            } else { SendClientMessage(playerid,red,"You already heave a bomb"); }
        } else { SendClientMessage(playerid,red,"You need $15000 for a bomb"); }
        return 1;
    }
    if(strcmp(cmdtext, "/plantbomb", true) == 0 || strcmp(cmdtext, "/pb", true) == 0)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            SendClientMessage(playerid,red,"You can't plant a bomb in a car");
        } else if(HasC4[playerid] == 1) {
            new Float:X,Float:Y,Float:Z;
            GetPlayerPos(playerid, X, Y, Z);
            bombs = CreateObject(1252,X,Y,Z,0,0,0);
            SendClientMessage(playerid,red,"The bomb will go off in 5 seconds");
            Bomb[playerid] = SetTimerEx("boom",5000,false,"i",playerid);
            HasC4[playerid] =0;
            C4Placed[playerid] =1;
        } else { SendClientMessage(playerid,red,"You dont have a bomb"); }
        return 1;
    }

//At Bottom
public boom(objectid, playerid)
{
    new Float:X,Float:Y,Float:Z;
    GetObjectPos(bombs,X,Y,Z);
    DestroyObject(bombs);
    CreateExplosion(X,Y,Z+2,2,10);
    CreateExplosion(X,Y,Z+2,2,10);
    CreateExplosion(X,Y-2,Z,2,10);
    CreateExplosion(X-2,Y,Z,2,10);
    SendClientMessage(playerid,red,"Bomb went off");
    return 1;
}
Works FINE, just you really might wanna run like shit when you /plantbomb its deadly xD


Re: error 003 - Ritchie999 - 11.08.2010

Your script works, But i want one that allows you to plant a bomb INSIDE a car.
I've already got a bomb for outside a car


Re: error 003 - willsuckformoney - 11.08.2010

pawn Код:
if(strcmp(cmdtext, "/plantbomb", true) == 0 || strcmp(cmdtext, "/pb", true) == 0)
    {
        if(HasC4[playerid] == 1) {
            new Float:X,Float:Y,Float:Z;
            GetPlayerPos(playerid, X, Y, Z);
            bombs = CreateObject(1252,X,Y,Z,0,0,0);
            SendClientMessage(playerid,red,"The bomb will go off in 5 seconds");
            Bomb[playerid] = SetTimerEx("boom",5000,false,"i",playerid);
            HasC4[playerid] =0;
            C4Placed[playerid] =1;
        } else { SendClientMessage(playerid,red,"You dont have a bomb"); }
        return 1;
    }



Re: error 003 - Ritchie999 - 11.08.2010

Alright just one more thing. I removed the
pawn Код:
Bomb[playerid] = SetTimerEx("boom",5000,false,"i",playerid);
out of Plant Bomb command, How could i make a detonate command out of that?


Re: error 003 - JaTochNietDan - 11.08.2010

Quote:
Originally Posted by Ritchie999
Посмотреть сообщение
Still get the same error on same line
Well, back to your original code.

pawn Код:
C4Placed[playerid =0];
should be
pawn Код:
C4Placed[playerid] = 0;



Re: error 003 - Ritchie999 - 11.08.2010

Changed that, Still getting that error though.
Heres the entire script

http://pastebin.com/rRn1tp0B