SA-MP Forums Archive
Anti-Vehicle Jacking - Problem - 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: Anti-Vehicle Jacking - Problem (/showthread.php?tid=406636)



Anti-Vehicle Jacking - Problem - dr.lozer - 11.01.2013

hi.. i got a problem in this anti-vehicle jacking (which is made by me xD ) and i need help to fix it :P

the problem is that when a player fall from vehicle and enter the vehicle it says "No Car Jacking" so player cant enter in that vehicle untill the vehicle get spawned

code:

pawn Код:
new vehicletaken[MAX_VEHICLES],
    passanger[MAX_PLAYERS]
;

public OnGameModeInit()
{
    for(new i=0;i != MAX_VEHICLES; i++) if(i != INVALID_VEHICLE_ID) {
        vehicletaken[i] = 0;
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    passanger[playerid] = -1;
   
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    passanger[playerid] = -1;
    return 1;
}

public OnPlayerSpawn(playerid)
{
   passanger[playerid] = -1;
   return 1;
}

public OnPlayerDeaths(playerid, killerid, reason)
{
   passanger[playerid] = -1;
   return 1;
}

public OnVehicleSpawn(vehicleid)
{
    vehicletaken[vehicleid] = 0;
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    vehicletaken[vehicleid] = 0;
    return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new Float:x,Float:y,Float:z,Float:a;
    GetPlayerPos(playerid, x,y,z); GetPlayerFacingAngle(playerid, a);
   
    if(!ispassenger) {
        if(vehicletaken[vehicleid] == 1) {
            SetPlayerPos(playerid, x,y,z); SetPlayerFacingAngle(playerid, a);
            GameTextForPlayer(playerid, "~r~No Car Jacking",1000,4);
        }else {
            vehicletaken[vehicleid] = 1;
            passanger[playerid] = ispassenger;
        }
    }
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(passanger[playerid] == 0) {
        vehicletaken[vehicleid] = 0;
        passanger[playerid] = -1;
    }
    return 1;
}



Re: Anti-Vehicle Jacking - Problem - dr.lozer - 11.01.2013

bump


Re : Anti-Vehicle Jacking - Problem - yusei - 11.01.2013

PHP код:
public OnPlayerEnterVehicle(playeridvehicleidispassenger)
{   
    if(!
ispassenger) {
       new 
Float:xFloat:yFloat:z;
       For(new 
0MAX_PLAYERS; ++i){
        if(
GetPlayerState(i) == PLAYER_STATE_DRIVER && != playerid) {
            
SetPlayerPos(playeridx,y,z+0.1); 
            
GameTextForPlayer(playerid"~r~No Car Jacking",1000,4);
        }else {
            
vehicletaken[vehicleid] = 1;
            
passanger[playerid] = ispassenger;
        }
       }
    }
    return 
1;




Re: Re : Anti-Vehicle Jacking - Problem - Threshold - 11.01.2013

Quote:
Originally Posted by yusei
Посмотреть сообщение
PHP код:
public OnPlayerEnterVehicle(playeridvehicleidispassenger)
{   
    if(!
ispassenger) {
       new 
Float:xFloat:yFloat:z;
       For(new 
0MAX_PLAYERS; ++i){
        if(
GetPlayerState(i) == PLAYER_STATE_DRIVER && != playerid) {
            
SetPlayerPos(playeridx,y,z+0.1); 
            
GameTextForPlayer(playerid"~r~No Car Jacking",1000,4);
        }else {
            
vehicletaken[vehicleid] = 1;
            
passanger[playerid] = ispassenger;
        }
       }
    }
    return 
1;

Holy crap, that wouldn't work at all...
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(ispassenger == 0)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(IsPlayerInVehicle(i, vehicleid))
                {
                    if(i != playerid)
                    {
                        if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
                        {
                            new Float:Pos[3];
                            GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
                            SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2] + 0.3);
                            GameTextForPlayer(playerid, "~r~No Car Jacking",1000,4);
                            break;
                        }
                    }
                }
            }
        }
    }
    return 1;
}



Re: Re : Anti-Vehicle Jacking - Problem - dr.lozer - 14.01.2013

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
Holy crap, that wouldn't work at all...
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(ispassenger == 0)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(IsPlayerInVehicle(i, vehicleid))
                {
                    if(i != playerid)
                    {
                        if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
                        {
                            new Float:Pos[3];
                            GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
                            SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2] + 0.3);
                            GameTextForPlayer(playerid, "~r~No Car Jacking",1000,4);
                            break;
                        }
                    }
                }
            }
        }
    }
    return 1;
}
Thanks Mate

can you explain me what does "break;" do


Re: Re : Anti-Vehicle Jacking - Problem - EAsT-OAK_510 - 14.01.2013

Quote:
Originally Posted by dr.lozer
Посмотреть сообщение
can you explain me what does "break;" do
Sam here. I forgot to ask that last time when you helped me out on a an issue I had with my code and "break" was added on it too.