SA-MP Forums Archive
Err's :@ - 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: Err's :@ (/showthread.php?tid=483664)



Err's :@ - Raza2013 - 27.12.2013

pawn Код:
#include <a_samp>

stock LazerStatus(playerid)    // this is a laser system
{
SetPVarInt(playerid, "laser", 0) return SetPVarInt(playerid, "laser", 1);
SetPVarInt(playerid, "color", GetPVarInt(playerid, "color"));  
ApplyAnimation(playerid,"PYTHON","python_crouchreload",4.1,0,0,0,0,0,1); // animation while loading laser pointer
}
else if(SetPVarInt(playerid, "laser", 1)); return SetPVarInt(playerid, "laser", 0); //Line 10
}
return 1; //Line 12
}
pawn Код:
D:\SA-MP Server\pawno\new.pwn(10) : error 010: invalid function or declaration
D:\SA-MP Server\pawno\new.pwn(12) : error 010: invalid function or declaration
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.



Re: Err's :@ - Voxel - 27.12.2013

Your calling a "else if" while you never called a single if statement in your stock
Try this:
pawn Код:
stock LazerStatus(playerid)    // this is a laser system
{
    if(SetPVarInt(playerid, "laser", 1));
    {
        SetPVarInt(playerid, "laser", 0);
    }
    else
    {
        SetPVarInt(playerid, "laser", 0) return SetPVarInt(playerid, "laser", 1);
        SetPVarInt(playerid, "color", GetPVarInt(playerid, "color"));  
        ApplyAnimation(playerid,"PYTHON","python_crouchreload",4.1,0,0,0,0,0,1); r
    }
    return 1;
}



Re: Err's :@ - Konstantinos - 27.12.2013

It will set laser to 1 and that's it - the rest of the code won't be called because you used return. You also need to GetPVarInt and not set in the if check. It's also pointless to set an already set value (the color).

pawn Код:
stock LazerStatus(playerid)
{
    if (!GetPVarInt(playerid, "laser")
    {
        SetPVarInt(playerid, "laser", 1);
        ApplyAnimation(playerid,"PYTHON","python_crouchreload",4.1,0,0,0,0,0,1); // animation while loading laser pointer
    }
    else SetPVarInt(playerid, "laser", 0);
}



Re: Err's :@ - J4mmyHD - 27.12.2013

pawn Код:
stock LazerStatus(playerid)    // this is a laser system
{
    if(SetPVarInt(playerid, "laser", 0))
    {
        SetPVarInt(playerid, "laser", 1);
        SetPVarInt(playerid, "color", GetPVarInt(playerid, "color"));  
        ApplyAnimation(playerid,"PYTHON","python_crouchreload",4.1,0,0,0,0,0,1);
    }
    else
    {
        SetPVarInt(playerid, "laser", 0);
    }
    return 1;
}
Your error was
pawn Код:
else if(SetPVarInt(playerid, "laser", 1)); return SetPVarInt(playerid, "laser", 0); //Line 10
You had a Semi Colon.


Re: Err's :@ - Raza2013 - 29.12.2013

[QUOTE=J4mmyHD;2836579]
pawn Код:
stock LazerStatus(playerid)    // this is a laser system
{
    if(SetPVarInt(playerid, "laser", 0))
    { // 7556 Line
        SetPVarInt(playerid, "laser", 1);
        SetPVarInt(playerid, "color", GetPVarInt(playerid, "color"));  
        ApplyAnimation(playerid,"PYTHON","python_crouchreload",4.1,0,0,0,0,0,1);
    }
    else
    {
        SetPVarInt(playerid, "laser", 0);
    }
    return 1;
}
pawn Код:
D:\SA-MP Server\gamemodes\Raza.pwn(7556) : error 001: expected token: ")", but found "{"



Re: Err's :@ - ToiletDuck - 29.12.2013

pawn Код:
if(SetPVarInt(playerid, "laser", 0)) // lool?
    {
use this

pawn Код:
if(GetPVarInt(playerid, "laser") == 0)
    {



Re: Err's :@ - Raza2013 - 31.12.2013

hmm brah's still not working can any one conevert it into OnPlayerKeyStateChange YES key?


Re: Err's :@ - Raza2013 - 31.12.2013

bump :/


Re: Err's :@ - Voxel - 01.01.2014

Allright uhm, try this
pawn Код:
//on top of your script
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_YES))
    {
        if (!GetPVarInt(playerid, "laser")
        {
            SetPVarInt(playerid, "laser", 1);
            ApplyAnimation(playerid,"PYTHON","python_crouchreload",4.1,0,0,0,0,0,1);
        }
        else SetPVarInt(playerid, "laser", 0);
    }
    return 1;
}