SA-MP Forums Archive
Gate script error - 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: Gate script error (/showthread.php?tid=367863)



Gate script error - jeremy8810 - 11.08.2012

Hey guys,

Whats wrong with this filter-script:
pawn Код:
#include <a_samp>
new Gate, bool:GateClosed = true;

public OnFilterScriptInit()
{
    Gate = CreateObject(968, 3268.3994140625, 150.5, 9.8999996185303, 0.0, 270.74993896484, 282.7470703125, 100.0);
    SetTimer("GateCheck", 3500, true);
    return 1;
}

forward GateCheck();
public GateCheck()
{
    if(!IsObjectMoving(Gate)){
        for(new i; i<GetMaxPlayers(); i++){
            if(IsPlayerConnected(i && IsPlayerInRangeOfPoint(i, 15.0, 3268.3994140625, 150.5, 9.8999996185303)){
                if(GateClosed){
                    GateClosed = false;
                    MoveObject(Gate, 3268.3994140625, 150.5, 9.8999996185303, 2.0, 0.0, 359.75006103516, 282.744140625);
                    SendClientMessage(i, 0xFF9D00FF, "You are ready to go!");
                }
                else{
                    GateClosed = true;
                    MoveObject(Gate, 3268.3994140625, 150.5, 9.8999996185303, 2.0, 0.0, 270.74993896484, 282.7470703125);
                    SendClientMessage(i, 0xFFFFFFFF, "");
            }
            }
        }
    }
}
First problem is fixed,

But why the gate isnt opening?

Please tell me what I did wrong...

Thanks


Re: Gate script error - telmo_ferreira - 11.08.2012

change this
if(IsPlayerConnected(i && IsPlayerInRangeOfPoint(i, 15.0, 3268.3994140625, 150.5, 9.8999996185303)){

to
if(IsPlayerConnected(i && IsPlayerInRangeOfPoint(i, 15.0, 3268.3994140625, 150.5, 9.8999996185303))){


Re: Gate script error - kickerbat - 11.08.2012

Код:
 if(IsPlayerConnected(i && IsPlayerInRangeOfPoint(i, 15.0, 3268.3994140625, 150.5, 9.8999996185303)){
change to;

Код:
 if(IsPlayerConnected(i && IsPlayerInRangeOfPoint(i, 15.0, 3268.3994140625, 150.5, 9.8999996185303))) {



Re: Gate script error - jeremy8810 - 11.08.2012

Thanks, its fixed + Rep!


Re: Gate script error - jeremy8810 - 11.08.2012

Another problem: Why the gate isnt opening?


Re: Gate script error - Vince - 11.08.2012

That's still wrong. The missing bracket should be after the i of IsPlayerConnected. But since a player can't be in range of a point when he's not connected, this check is completely redundant and can be left out completely. Just use this.

pawn Код:
if(IsPlayerInRangeOfPoint(i, 15.0, 3268.3994140625, 150.5, 9.8999996185303)) {



Re: Gate script error - jeremy8810 - 11.08.2012

thanks, but the gate is opening but not closing :S
pawn Код:
#include <a_samp>
new Gate, bool:GateClosed = true;

public OnFilterScriptInit()
{
    Gate = CreateObject(968, 3268.3994140625, 150.5, 9.8999996185303, 0.0, 270.74993896484, 282.7470703125, 100.0);
    SetTimer("GateCheck", 3500, true);
    return 1;
}

forward GateCheck();
public GateCheck()
{
    if(!IsObjectMoving(Gate)){
        for(new i; i<GetMaxPlayers(); i++){
            if(IsPlayerInRangeOfPoint(i, 15.0, 3268.3994140625, 150.5, 9.8999996185303)) {
                if(GateClosed){
                    GateClosed = false;
                    MoveObject(Gate, 3268.3994140625, 150.5, 9.8999996185303, 2.0, 0.0, 359.75006103516, 282.744140625);
                    SendClientMessage(i, 0xFF9D00FF, "You are ready to go!");
                }
                else{
                    GateClosed = true;
                    MoveObject(Gate, 3268.3994140625, 150.5, 9.8999996185303, 2.0, 0.0, 270.74993896484, 282.7470703125);
            }
            }
        }
    }
}



Re: Gate script error - jeremy8810 - 11.08.2012

bump


Re: Gate script error - PArescueEMT - 11.08.2012

i may be wrong, but i may have found a simple error... i personally script all my gates with 2 commands. 1 for open and 1 for close, but i think the issue could be

pawn Код:
#include <a_samp>
new Gate, bool:GateClosed = true;

public OnFilterScriptInit()
{
    Gate = CreateObject(968, 3268.3994140625, 150.5, 9.8999996185303, 0.0, 270.74993896484, 282.7470703125, 100.0);
    SetTimer("GateCheck", 3500, true);
    return 1;
}

forward GateCheck();
public GateCheck()
{
    if(!IsObjectMoving(Gate)){
        for(new i; i<GetMaxPlayers(); i++){
            if(IsPlayerInRangeOfPoint(i, 15.0, 3268.3994140625, 150.5, 9.8999996185303)) {
                if(GateClosed){
                    GateClosed = false;
                    MoveObject(Gate, 3268.3994140625, 150.5, 9.8999996185303, 2.0, 0.0, 359.75006103516, 282.744140625);
                    SendClientMessage(i, 0xFF9D00FF, "You are ready to go!");
                    return 1;
                } else {
                    GateClosed = true;
                    MoveObject(Gate, 3268.3994140625, 150.5, 9.8999996185303, 2.0, 0.0, 270.74993896484, 282.7470703125);
                    return 1;
            }
            }
        }
    }
all i have done is added a simple "return 1;" to each of the commands. not sure if that is the issue on this one, but without that, it was processing straight through and not pausing to verify the previous command.

hope this helps..