i got a problem with LOOPING
#1

i use a loop in automatic gate and car script and in both it doesnt work properly

this is the loop i use

pawn Код:
for(new i=0; i<MAX_PLAYERS; i++)
{
}
idk why its not working

here
pawn Код:
forward gatecheck();
public gatecheck()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInRangeOfPoint(i, 15.0,1545.93554688,-1626.52050781,12.58281231))
            {
                MoveObject(lspleftgate, 1545.93554688,-1617.52050781,12.58281231, 5.0);
                MoveObject(lsprightgate, 1545.93554688,-1635.82055664,12.58281231, 5.0);
            }
            else if(IsPlayerInRangeOfPoint(i, 15.0, 1140.91699219,-1292.01171875,12.68227100))
            {
                MoveObject(lsmgate1, 1148.21447754,-1292.01245117,12.68227100, 5.0);
                MoveObject(lsmgate2, 1133.91699219,-1292.01171875,12.68227100, 5.0);
            }
            else if(IsPlayerInRangeOfPoint(i, 15.0, 1591.87133789,-1638.18017578,13.89877319))
            {
                MoveObject(lspgar, 1591.87133789, -1638.18017578, 6.89877319, 5.0);
            }
            else
            {
                MoveObject(lspleftgate, 1545.93554688,-1626.52050781,12.58281231, 5.0);
                MoveObject(lsprightgate, 1545.93554688,-1626.82055664,12.58281231, 5.0);
                MoveObject(lsmgate1, 1141.21447754,-1292.01245117,12.68227100, 5.0);
                MoveObject(lsmgate2, 1140.91699219,-1292.01171875,12.68227100, 5.0);
            }
        }
    }
    return 1;
}
it works well when iam alone in the server but when someone connects it doesnt work ir opens for him and doesnt open for me and its not the first time it happens

about the car i made a FS it destroy the car and create it back and its supposed to put the players(if there is players in the car) again in the new created car

and it also dont work only one player is putted in the new car and the other is removed

i used foreach.inc by ****** here and it didnt work lol
pawn Код:
if(PRESSED(KEY_ANALOG_DOWN))
    {
        if(!IsPlayerAdmin(playerid)) return 0;
        else
        {
            if(ATTACK == 1)
            {
                GetVehiclePos(OMGCAR[0], CX, CY, CZ);
                GetVehicleZAngle(OMGCAR[0], CA);
                GetVehicleVelocity(OMGCAR[0], VX, VY, VZ);
                foreach(Player, i)
                {
                    if(IsPlayerInVehicle(i, OMGCAR[0]))
                    {
                        new seat = GetPlayerVehicleSeat(i);
                        DestroyVehicle(OMGCAR[0]);
                        OMGCAR[0] = CreateVehicle(522, CX, CY, CZ, CA, 0, 1, 0);
                        PutPlayerInVehicle(i, OMGCAR[0], seat);
                        SetVehicleVelocity(OMGCAR[0], VX, VY, VZ);
                    }
                }
            }
        }
    }
please tell me wth is going on with the loop
Reply
#2

Where is gatecheck() called? Post the line where that is used.
Reply
#3

I can only give the same answer at your previous thread:
https://sampforum.blast.hk/showthread.php?tid=241856
Reply
#4

Quote:
Originally Posted by randomkid88
Посмотреть сообщение
Where is gatecheck() called? Post the line where that is used.
its with a timer so its called every 1sec


Quote:
Originally Posted by Biesmen
Посмотреть сообщение
I can only give the same answer at your previous thread:
https://sampforum.blast.hk/showthread.php?tid=241856
and i will tell you the same thing its not working and the problem is not only with the gate the problem is the loop i tried gatecheck(playerid) and what you got to say about the car ??
Reply
#5

About the car:
I removed that } else at the beginning, that could be one of the problem(s).
Also, please answer the questions in this script:
pawn Код:
if(PRESSED(KEY_ANALOG_DOWN))
    {
        if(!IsPlayerAdmin(playerid)) return 0; // This 'function' will not work if a player is not a RCON admin
            if(ATTACK == 1) // Are you sure the variable is 1 for the server?
            {
                GetVehiclePos(OMGCAR[0], CX, CY, CZ); // Where did you define XC, CY, CZ?
                GetVehicleZAngle(OMGCAR[0], CA); // Where did you define CA?
                GetVehicleVelocity(OMGCAR[0], VX, VY, VZ); // Where did you define VX,VY,VZ
                foreach(Player, i) // Where are you using this whole function? Why not at OnPlayerUpdate, so you don't have to use loops.
                {
                    if(IsPlayerInVehicle(i, OMGCAR[0])) // Isn't it a bit too late to check if the player is in a vehicle if the information of this vehicle is stored above?
                    {
                        new seat = GetPlayerVehicleSeat(i);
                        DestroyVehicle(OMGCAR[0]);
                        OMGCAR[0] = CreateVehicle(522, CX, CY, CZ, CA, 0, 1, 0);
                        PutPlayerInVehicle(i, OMGCAR[0], seat);
                        SetVehicleVelocity(OMGCAR[0], VX, VY, VZ);
                    }
                }
            }
    }
Reply
#6

ok

About the "ATTACK" attack is defined as 1 when the player press something and its not the problem

about the defines i defined them after the #includes and i dont get any errors or warnings

idk

maybe its late but it should work anyway
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)