SA-MP Forums Archive
Else Probblem - 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: Else Probblem (/showthread.php?tid=505840)



Else Probblem - gekas - 10.04.2014

Can to Fix This Problem ?

Quote:

dcmd_bot(playerid,params[])
{
#pragma unused params
if(pInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid, COLOR_RED, ""ERROR_MESSAGE"");
{
SetPlayerAttachedObject( playerid, 0, 19078, 1, 0.337255, -0.102219, -0.170282, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
}
else
{
RemovePlayerAttachedObject(playerid, 1907;
}
return 1;
}

Quote:

C:\Users\Arlind\Desktop\fsdf\filterscripts\Project .pwn(5919) : error 029: invalid expression, assumed zero




Re: Else Probblem - gekas - 10.04.2014

Can to help mee ?


Re: Else Probblem - Danijel. - 10.04.2014

which is line 5919?


Re: Else Probblem - Konstantinos - 10.04.2014

You suddenly open a bracket and then you use else statement without an if before. I'm not aware of what your command is supposed to do so either:
pawn Код:
dcmd_bot(playerid,params[])
{
    #pragma unused params
    if(pInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid, COLOR_RED, ""ERROR_MESSAGE"");
    if (/* SOME EXPRESSION */)
    {
        SetPlayerAttachedObject( playerid, 0, 19078, 1, 0.337255, -0.102219, -0.170282, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
    }
    else
    {
        RemovePlayerAttachedObject(playerid, 1907;
    }
    return 1;
}
or
pawn Код:
dcmd_bot(playerid,params[])
{
    #pragma unused params
    if(pInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid, COLOR_RED, ""ERROR_MESSAGE"");
    SetPlayerAttachedObject( playerid, 0, 19078, 1, 0.337255, -0.102219, -0.170282, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
    RemovePlayerAttachedObject(playerid, 1907;
    return 1;
}
That depends on you.


Re: Else Probblem - RoboN1X - 10.04.2014

It's because you are returning the if statement then adding else in the next, like konstantinos said

Or you probably wanted like this:
pawn Код:
dcmd_bot(playerid,params[])
{
    #pragma unused params
    if(pInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid, COLOR_RED, ""ERROR_MESSAGE""); // if not an admin, then send error
    else
    { // if playerid's adminlevel > 0 then process
        if(IsPlayerAttachedObjectSlotUsed(playerid, 0)) // check if there is an attached object already (in slot 0)
        {
            RemovePlayerAttachedObject(playerid, 0); // remove the attached object (from slot 0)
        }
        else // or if not attached
        {
            SetPlayerAttachedObject(playerid, 0, 19078, 1, 0.337255, -0.102219, -0.170282, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000); // set the player attached object (as slot 0)
        }
    }
    return 1;
}