Stop player from entering vehicle
#6

Quote:
Originally Posted by AmigaBlizzard
View Post
RemovePlayerFromVehicle would only work if he's already inside the vehicle.
I think he wants to know how to prevent anyone to even enter the vehicle, like it would be as if the doors are locked.

Everytime a player logs in, you can process all vehicles and set the doors locked/unlocked based on the ownership of the vehicle.

Pseudocode:
Code:
// Loop through all vehicles
for vid = 0 to 1999
	// Check if this vehicle exists
	if (VehicleData[vid][VehicleExists] == 1)
		// Loop through all players
		for playerid = 0 to MAX_PLAYERS
			// Check if this player is connected
			if IsPlayerConnected(playerid)
				// Check if this player is the owner
				if (GetPlayerName(playerid) == VehicleData[vid][Owner])
					// Unlock the doors for the owner
					SetVehicleParamsForPlayer(vid, playerid, 0, 0)
				else
					// Lock the doors for every other player
					SetVehicleParamsForPlayer(vid, playerid, 0, 1)
				endif
			endif
		next
	endif
next
exactly, I just didn't know that there's a function to lock doors so I wanted to do it on my own :P anyway, how can I show that little message box at the left of the screen, not dialog box, but some kind of message box, I hope you know what I mean

edit: + I have this code, but since I'm testing it on local machine without any players I hav eno idea if it is working, but it should lock/unlock doors when I use command /dvere, however I can enter vehicle even if I locked it, but I can't test it with other players since I'm testing it on local machine... soo what I think this is doing is that it will lock doors for everyone except me, am I right? I have same code but with engine and it is working for turning it off/on, + how does alarm works? I've never seen it before

pawn Code:
if(!strcmp("/dvere", cmdtext))
    {
        if(GetPlayerVehicleID(playerid) != 0)
        {
            new motor, svetla, alarm, dvere, kapota, kufor, obj;
            GetVehicleParamsEx(GetPlayerVehicleID(playerid), motor, svetla, alarm, dvere, kapota, kufor, obj);
            if(dvere == 0)
                dvere = 1;
            else
                dvere = 0;
            SetVehicleParamsEx(GetPlayerVehicleID(playerid), motor, svetla, alarm, dvere, kapota, kufor, obj);
        }
        return 1;
    }
Reply


Messages In This Thread
Stop player from entering vehicle - by SEnergy - 27.07.2012, 18:10
Re: Stop player from entering vehicle - by maramizo - 27.07.2012, 18:14
Re: Stop player from entering vehicle - by SEnergy - 27.07.2012, 18:21
Re: Stop player from entering vehicle - by [KHK]Khalid - 27.07.2012, 18:25
Re: Stop player from entering vehicle - by AmigaBlizzard - 27.07.2012, 18:25
Re: Stop player from entering vehicle - by SEnergy - 27.07.2012, 18:40
Re: Stop player from entering vehicle - by [KHK]Khalid - 27.07.2012, 19:05
Re: Stop player from entering vehicle - by Universal - 27.07.2012, 19:07
Re: Stop player from entering vehicle - by [KHK]Khalid - 27.07.2012, 19:17
Re: Stop player from entering vehicle - by Universal - 27.07.2012, 19:41

Forum Jump:


Users browsing this thread: 1 Guest(s)