SA-MP Forums Archive
[TUT] Lock vehicles by name(s) - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [TUT] Lock vehicles by name(s) (/showthread.php?tid=158395)



[TUT] Lock vehicles by name(s) - Mike Garber - 09.07.2010

pawn Код:
public OnVehicleStreamIn(vehicleid, forplayerid)
{

    // ONE NAME ONLY
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(forplayerid, playername, sizeof(playername));

       if(vehicleid >= 000){ // What vehicleid (ONE VEHICLE)
    if(strfind(playername, "Mike_Garber", true) == -1){ // Type whatever name you want to have access
    SetVehicleParamsForPlayer(vehicleid,forplayerid,0,1); // If It's not that name, It will lock
    }else{
    SetVehicleParamsForPlayer(vehicleid,forplayerid,0,0); // else, (if he got the correct name) unlock.
    }
    }


// SEVERAL NAMES
 // new playername[MAX_PLAYER_NAME]; // RE-ENABLE IF YOU DON'T USE THE CODE ABOVE
 // GetPlayerName(forplayerid, playername, sizeof(playername)); // RE-ENABLE IF YOU DONT USE THE CODE ABOVE

    if(vehicleid >= 000 && vehicleid <= 001){ // Vehicle ID between the first and the last value
    if(strfind(playername, "Mike_Garber", true) == -1 || strfind(playername, "James_Smith", true) == -1){ // Type whatever names you want to have access
    SetVehicleParamsForPlayer(vehicleid,forplayerid,0,1); // If It's not that name, It will lock
    }else{
    SetVehicleParamsForPlayer(vehicleid,forplayerid,0,0); // else, (if he got the correct name) unlock.
    }
    }
}
Easy, fast and less code then the other thread.
You have to intendent the code as I modified it on the forums xD