SA-MP Forums Archive
Other person driving a car looks like not driving a car? - 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: Other person driving a car looks like not driving a car? (/showthread.php?tid=580376)



Other person driving a car looks like not driving a car? - Capua - 04.07.2015

So I just noticed this thing in my server. When I enter as a driver I can drive the car around, but anyone else can't see me driving, just sitting on the seat. Also I can't see anyone else driving, I entered friend's vehicle as passenger, he was just standing still in my screen, but suddenly the textures started to disappear and he said he was driving away. What is this?


Re: Other person driving a car looks like not driving a car? - Lynn - 04.07.2015

This is a problem on your end. I suggest first, reinstalling SAMP if that doesn't fix the issue reinstall GTA:SA.
Odd's are you will have to reinstall your game inorder to fix the issue.


Re: Other person driving a car looks like not driving a car? - Capua - 04.07.2015

I'm talking about my server. I can see others and others can see me driving on other servers. I don't understand what would cause this.


Re: Other person driving a car looks like not driving a car? - liquor - 05.07.2015

Sounds like an issue with OnPlayerUpdate.. Anticheat system maybe, or just a bad connection.


Re: Other person driving a car looks like not driving a car? - Capua - 24.07.2015

I'm having a home host, but it's a 100 MB fibre optic. No connection problems. Running server on SSD. I don't have much of code under OnPlayerUpdate, only these:
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(gPlayerInfo[playerid][pTeam] == TEAM_MARINES)
    {
        AvoidSAMAttacksOnPlayer(playerid, usabasesam);
    }
    else if(gPlayerInfo[playerid][pTeam] != TEAM_MARINES)
    {
        EnableSAMAttacksOnPlayer(playerid, usabasesam);
    }
    if(IsSAMMissileChasing(playerid) && samwarning[playerid] == 0)
    {
        SendClientMessage(playerid, RED, "**RADAR WARNING:::SAM TARGETED**");
        samwarning[playerid] = 1;
        PlayerPlaySound(playerid,1138,0.0,0.0,0.0);
        SetTimerEx("SamWarnTimer", 3000, 0, "i", playerid);
    }
    if(!IsPlayerInAnyVehicle(playerid))
    {
        AvoidSAMAttacksOnPlayer(playerid, usabasesam);
    }
    //SAM targeting only aircraft & not marines
    new isincar = GetPlayerState(playerid);
    if(isincar == PLAYER_STATE_DRIVER || isincar == PLAYER_STATE_PASSENGER)
    {
        if(gPlayerInfo[playerid][pTeam] == TEAM_MARINES) return 0;
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 520 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 425 ||
        GetVehicleModel(GetPlayerVehicleID(playerid)) == 447 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 432 ||
        GetVehicleModel(GetPlayerVehicleID(playerid)) == 548 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 417 ||
        GetVehicleModel(GetPlayerVehicleID(playerid)) == 487 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 488 ||
        GetVehicleModel(GetPlayerVehicleID(playerid)) == 497 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 563 ||
        GetVehicleModel(GetPlayerVehicleID(playerid)) == 469 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 460 ||
        GetVehicleModel(GetPlayerVehicleID(playerid)) == 476 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 511 ||
        GetVehicleModel(GetPlayerVehicleID(playerid)) == 512 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 513 ||
        GetVehicleModel(GetPlayerVehicleID(playerid)) == 519 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 553 ||
        GetVehicleModel(GetPlayerVehicleID(playerid)) == 577 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 592 ||
        GetVehicleModel(GetPlayerVehicleID(playerid)) == 593)
        {
            EnableSAMAttacksOnPlayer(playerid, usabasesam);
        }
        else AvoidSAMAttacksOnPlayer(playerid, usabasesam);
    }
    return 1;
}
Got any ideas?


Re: Other person driving a car looks like not driving a car? - xVIP3Rx - 24.07.2015

pawn Код:
if(gPlayerInfo[playerid][pTeam] == TEAM_MARINES) return 0;
Never return 0 on onplayerupdate, it'll act like you aren't there.


Re: Other person driving a car looks like not driving a car? - JaydenJason - 24.07.2015

Код:
if(gPlayerInfo[playerid][pTeam] == TEAM_MARINES) return 0;



Re: Other person driving a car looks like not driving a car? - Capua - 24.07.2015

So I could use continue; instead of return 0; ?


Re: Other person driving a car looks like not driving a car? - xVIP3Rx - 24.07.2015

No, just check the opposite state and open a bracket after it, I've optimized this code for you, uncompiled though

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(gPlayerInfo[playerid][pTeam] == TEAM_MARINES || !IsPlayerInAnyVehicle(playerid))         AvoidSAMAttacksOnPlayer(playerid, usabasesam);
    else if(gPlayerInfo[playerid][pTeam] != TEAM_MARINES)                                       EnableSAMAttacksOnPlayer(playerid, usabasesam);

    if(IsSAMMissileChasing(playerid) && samwarning[playerid] == 0)
    {
        SendClientMessage(playerid, RED, "**RADAR WARNING:::SAM TARGETED**");
        samwarning[playerid] = 1;
        PlayerPlaySound(playerid,1138,0.0,0.0,0.0);
        SetTimerEx("SamWarnTimer", 3000, 0, "i", playerid);
    }
   
    //SAM targeting only aircraft & not marines
    new state = GetPlayerState(playerid);
    if(gPlayerInfo[playerid][pTeam] != TEAM_MARINES && (state == PLAYER_STATE_DRIVER || state == PLAYER_STATE_PASSENGER))
    {
        switch(GetVehicleModel(GetPlayerVehicleID(playerid))
        {
            case 520, 425, 447, 432, 548, 417, 487, 488, 497, 563, 469, 460, 476, 511, 512, 513, 519, 553, 577, 592, 593:
            {
                EnableSAMAttacksOnPlayer(playerid, usabasesam);
            }
            default:
            {
                AvoidSAMAttacksOnPlayer(playerid, usabasesam);
            }
        }
    }
    return 1;
}
Also incase you wanna use it as a timer
pawn Код:
public OnGameModeInit()
{
    SetTimer("OneSecondTimer", 1000, 1);
        return 1;
}

forward OneSecondTimer();
public OneSecondTimer()
{
    for(new playerid; playerid<MAX_PLAYERS; playerid++)//You should use foreach or playerpoolsize(0.3.7 R2) instead
    {
        if(gPlayerInfo[playerid][pTeam] == TEAM_MARINES || !IsPlayerInAnyVehicle(playerid))         AvoidSAMAttacksOnPlayer(playerid, usabasesam);
        else if(gPlayerInfo[playerid][pTeam] != TEAM_MARINES)                                       EnableSAMAttacksOnPlayer(playerid, usabasesam);

        if(IsSAMMissileChasing(playerid) && samwarning[playerid] == 0)
        {
            SendClientMessage(playerid, RED, "**RADAR WARNING:::SAM TARGETED**");
            samwarning[playerid] = 1;
            PlayerPlaySound(playerid,1138,0.0,0.0,0.0);
            SetTimerEx("SamWarnTimer", 3000, 0, "i", playerid);
        }

        //SAM targeting only aircraft & not marines
        new state = GetPlayerState(playerid);
        if(gPlayerInfo[playerid][pTeam] != TEAM_MARINES && (state == PLAYER_STATE_DRIVER || state == PLAYER_STATE_PASSENGER))
        {
            switch(GetVehicleModel(GetPlayerVehicleID(playerid))
            {
                case 520, 425, 447, 432, 548, 417, 487, 488, 497, 563, 469, 460, 476, 511, 512, 513, 519, 553, 577, 592, 593:
                {
                    EnableSAMAttacksOnPlayer(playerid, usabasesam);
                }
                default:
                {
                    AvoidSAMAttacksOnPlayer(playerid, usabasesam);
                }
            }
        }
    }
    return 1;
}



Re: Other person driving a car looks like not driving a car? - Capua - 24.07.2015

Omg why didn't I think about switch! The method I used probably was the issue and I'll test the now one asap. Thanks a lot!