Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] Gate System

 
  • 0 Vote(s) - 0 Average
Pawn Gate System
Regicide
Offline

Burgershot Member
Posts: 1
Threads: 1
Joined: Jun 2021
Reputation: 0
#1
2021-06-15, 11:44 PM (This post was last modified: 2021-06-15, 11:45 PM by Regicide.)
Okay so, for some reason when more than one gate loads it goes to shit the second gate moves to the position of the first gate, the third gate moves to the second gate position, and so on, why is this happening?

PHP Code:
enum _GateEnum
{
    GateID,
    Float:gate_place[4],
    Float:grX,
    Float:grY,
    Float:grZ,
   GateFaction,
   GateModel,
   GateObject,
   GateStatus
} 

PHP Code:
new Gates[MAX_GATES][_GateEnum]; 

PHP Code:
new Iterator:server_gates<MAX_GATES>; 

PHP Code:
load_gates()
{
    inline LoadGates()
    {
        if(!cache_num_rows())
        {
            printf("[MYSQL]: No Gate data found!");
            return 0;
        }
        foreach (new i : Range(0, cache_num_rows())) 
        {
            cache_get_value_int(i, "id", Gates[i][GateID]);
            cache_get_value_float(i, "x", Gates[i][gate_place][0]);
            cache_get_value_float(i, "y", Gates[i][gate_place][1]);
            cache_get_value_float(i, "z", Gates[i][gate_place][2]);

            cache_get_value_float(i, "rx", Gates[i][grX]);
            cache_get_value_float(i, "ry", Gates[i][grY]);
            cache_get_value_float(i, "rz", Gates[i][grZ]);
            cache_get_value_int(i, "faction", Gates[i][GateFaction]);
            cache_get_value_int(i, "model", Gates[i][GateModel]);

            Gates[i][GateStatus] = 0;

            Gates[i][GateObject] = CreateObject(Gates[i][GateModel], Gates[i][gate_place][0], Gates[i][gate_place][1], Gates[i][gate_place][2], Gates[i][grX], Gates[i][grY], Gates[i][grZ], 300.0);

            Iter_Add(server_gates, i);
        }
        printf("%d gates loaded.", i);
        return 1;
    }
    MySQL_TQueryInline(g_SQL, using inline LoadGates, "SELECT * FROM `server_gates`");
    return 1;
} 

PHP Code:
YCMD:gate(playerid, params[], help)
{
    foreach(new i:server_gates)
    {
        if(IsPlayerInRangeOfPoint(playerid, 5, Gates[i][gate_place][0], Gates[i][gate_place][1], Gates[i][gate_place][2]))
        {
            if(user_faction[playerid] == Gates[i][GateFaction])
            {
                if(Gates[i][GateStatus] == 0)
                {
                    MoveObject(Gates[i][GateObject], Gates[i][gate_place][0], Gates[i][gate_place][1], Gates[i][gate_place][2] -7.0, 3.0);
                    Gates[i][GateStatus] = 1;
                }
                else 
                {
                    MoveObject(Gates[i][GateObject], Gates[i][gate_place][0], Gates[i][gate_place][1], Gates[i][gate_place][2], 3.0);
                    Gates[i][GateStatus] = 0;
                }  
            
}
            else
            {
                SendClientMessage(playerid, -1, "[SERVER] You don't have access to this gate!");
            }
        }
        else
        {
            SendClientMessage(playerid, -1, "[SERVER]: You're not near any gate!");
        }
    }
    return 1;
} 
[Image: RZs4wDF.png?width=500&height=200]
« Next Oldest | Next Newest »



Messages In This Thread
Gate System - by Regicide - 2021-06-15, 11:44 PM
RE: Gate System - by Kwarde - 2021-06-16, 11:22 AM

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode