SA-MP Forums Archive
Vehicles and permissions - 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: Vehicles and permissions (/showthread.php?tid=292027)



Vehicles and permissions - Artie_Scorpion - 22.10.2011

I need one function which ejects player from vehicle if he didn't have needed skin...
P.S when player enter vehicle i need text when he got ejected. ex: You can't drive this..


Re: Vehicles and permissions - Henkie - 22.10.2011

Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == 2)
{
 if(!GetPlayerSkin == theskinidyouwant)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "You can't drive this vehicle.");
}
}
}
This should work.


Re: Vehicles and permissions - AeroBlast - 22.10.2011

pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid) == vid //Fill in the vehicle id
    {
        if(GetPlayerSkin(playerid) != skin) //Fill in the skin
        {
            RemovPlayerFromVehicle(playerid);
            SendClientMessage(playerid,0xFF0000FF, "you cant drive this");
        }
    }
    return 1;
}



Re: Vehicles and permissions - Artie_Scorpion - 22.10.2011

Quote:
Originally Posted by AeroBlast
View Post
pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid) == vid //Fill in the vehicle id
    {
        if(GetPlayerSkin(playerid) != skin) //Fill in the skin
        {
            RemovPlayerFromVehicle(playerid);
            SendClientMessage(playerid,0xFF0000FF, "you cant drive this");
        }
    }
    return 1;
}
I was got this error

Code:
C:\Users\Root\Desktop\Serveris\gamemodes\Untitled.pwn(207) : error 029: invalid expression, assumed zero



Re: Vehicles and permissions - SuperViper - 22.10.2011

pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid) == vid) //Fill in the vehicle id
    {
        if(GetPlayerSkin(playerid) != skin) //Fill in the skin
        {
            RemovPlayerFromVehicle(playerid);
            SendClientMessage(playerid,0xFF0000FF, "you cant drive this");
        }
    }
    return 1;
}



Re: Vehicles and permissions - Artie_Scorpion - 22.10.2011

Damn guys thats not working, i was not ejected from car if i didn't got skin 27


Re: Vehicles and permissions - AeroBlast - 22.10.2011

pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid) == vid) //Fill in the vehicle id
    {
        if(GetPlayerSkin(playerid) != skin) //Fill in the skin
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid,0xFF0000FF, "you cant drive this");
        }
    }
    return 1;
}
Forgot the e in RemovePlayerFromVehicle.. :/


Re: Vehicles and permissions - Artie_Scorpion - 22.10.2011

Quote:
Originally Posted by AeroBlast
View Post
pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid) == vid) //Fill in the vehicle id
    {
        if(GetPlayerSkin(playerid) != skin) //Fill in the skin
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid,0xFF0000FF, "you cant drive this");
        }
    }
    return 1;
}
Forgot the e in RemovePlayerFromVehicle.. :/
Not that i mean
When iam enter vehicle without skin 27 iam still can enter, but i want to enter vehicle (only) with skin 27


Re: Vehicles and permissions - Henkie - 22.10.2011

For any vehicle or just for a specific vehicle?


Re: Vehicles and permissions - Artie_Scorpion - 22.10.2011

Quote:
Originally Posted by [PC]henkie[NL]
View Post
For any vehicle or just for a specific vehicle?
for specific


Re: Vehicles and permissions - AeroBlast - 22.10.2011

Did you replace the 'vid' in if(newstate == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid) == vid) with that vehicle ID?


Re: Vehicles and permissions - Artie_Scorpion - 22.10.2011

Quote:
Originally Posted by AeroBlast
View Post
Did you replace the 'vid' in if(newstate == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid) == vid) with that vehicle ID?
yes!


Re: Vehicles and permissions - Henkie - 22.10.2011

Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate == 2)
	{
		if(GetPlayerSkin(playerid) == skin %% GetVehicleModel(GetPlayerVehicleID(playerid)) == car)// replace skin with the skin id you want, replace car with the carmodel id you want.
		{
			SendClientMessage(playerid, color, "Welcome to your car!"); // Replace color with the color you want
		}
		else
		{
		    RemovePlayerFromVehicle(playerid);
		    SendClientMessage(playerid, color, "You are not allowed to drive this car!"); //replace color with the color you want
		}
	}
	return 1;
}
That should work.


Re: Vehicles and permissions - Artie_Scorpion - 22.10.2011

Quote:
Originally Posted by [PC]henkie[NL]
View Post
Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate == 2)
	{
		if(GetPlayerSkin(playerid) == skin %% GetVehicleModel(GetPlayerVehicleID(playerid)) == car)// replace skin with the skin id you want, replace car with the carmodel id you want.
		{
			SendClientMessage(playerid, color, "Welcome to your car!"); // Replace color with the color you want
		}
		else
		{
		    RemovePlayerFromVehicle(playerid);
		    SendClientMessage(playerid, color, "You are not allowed to drive this car!"); //replace color with the color you want
		}
	}
	return 1;
}
That should work.
error:

Code:
C:\Users\Root\Desktop\Serveris\gamemodes\Untitled.pwn(214) : error 029: invalid expression, assumed zero
C:\Users\Root\Desktop\Serveris\gamemodes\Untitled.pwn(214) : warning 215: expression has no effect
C:\Users\Root\Desktop\Serveris\gamemodes\Untitled.pwn(214) : error 001: expected token: ";", but found ")"
C:\Users\Root\Desktop\Serveris\gamemodes\Untitled.pwn(214) : error 029: invalid expression, assumed zero
C:\Users\Root\Desktop\Serveris\gamemodes\Untitled.pwn(214) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.



Re: Vehicles and permissions - Henkie - 23.10.2011

Quote:
Originally Posted by Artie_Scorpion
View Post
error:

Code:
C:\Users\Root\Desktop\Serveris\gamemodes\Untitled.pwn(214) : error 029: invalid expression, assumed zero
C:\Users\Root\Desktop\Serveris\gamemodes\Untitled.pwn(214) : warning 215: expression has no effect
C:\Users\Root\Desktop\Serveris\gamemodes\Untitled.pwn(214) : error 001: expected token: ";", but found ")"
C:\Users\Root\Desktop\Serveris\gamemodes\Untitled.pwn(214) : error 029: invalid expression, assumed zero
C:\Users\Root\Desktop\Serveris\gamemodes\Untitled.pwn(214) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Did you copied properly? Because when I compile, it totally works. Did you replace the skin etc, like i said in the comments?


Re: Vehicles and permissions - Artie_Scorpion - 23.10.2011

Quote:
Originally Posted by [PC]henkie[NL]
View Post
Did you copied properly? Because when I compile, it totally works. Did you replace the skin etc, like i said in the comments?





Re: Vehicles and permissions - AeroBlast - 23.10.2011

pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2)
    {
        if(GetPlayerSkin(playerid) == skin && GetVehicleModel(GetPlayerVehicleID(playerid)) == car)// replace skin with the skin id you want, replace car with the carmodel id you want.
        {
            SendClientMessage(playerid, color, "Welcome to your car!"); // Replace color with the color you want
        }
        else
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, color, "You are not allowed to drive this car!"); //replace color with the color you want
        }
    }
    return 1;
}
There was: '%%'. It should be: '&&'.


Re: Vehicles and permissions - Henkie - 23.10.2011

whoops, sorry, i pressed the wrong button on my keyboard xd it must be &&, i'm sorry. The rest of the script should work.


Re: Vehicles and permissions - zT KiNgKoNg - 07.07.2012

Quote:
Originally Posted by Artie_Scorpion
View Post
for specific
Do This

pawn Code:
//Put This At The Top
new vtest;
//Put vtest = CreateVehicle(520, 1946.0304, -2346.7761, 14.5325, 0.0000, -1, -1, 100);
//public OnGameModeInit()
//{
    // Don't use these lines if it's a filterscript
//  SetGameModeText("Blank Script");
//  vtest = CreateVehicle(520, 1946.0304, -2346.7761, 14.5325, 0.0000, -1, -1, 100);
//  return 1;
//}
//This is the hydra it will spawn at LS airport just past the main entrance
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid) == vtest //Fill in the vehicle id
    {
        if(GetPlayerSkin(playerid) != 26) //Fill in the skin
        {
            RemovPlayerFromVehicle(playerid);
            SendClientMessage(playerid,0xFF0000FF, "you cant drive this");
        }
    }
    return 1;
}



Re: Vehicles and permissions - Steven82 - 07.07.2012

Quote:
Originally Posted by Ultra-Gaming
View Post
Do This

pawn Code:
//Put This At The Top
new vtest;
//Put vtest = CreateVehicle(520, 1946.0304, -2346.7761, 14.5325, 0.0000, -1, -1, 100);
//public OnGameModeInit()
//{
    // Don't use these lines if it's a filterscript
//  SetGameModeText("Blank Script");
//  vtest = CreateVehicle(520, 1946.0304, -2346.7761, 14.5325, 0.0000, -1, -1, 100);
//  return 1;
//}
//This is the hydra it will spawn at LS airport just past the main entrance
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid) == vtest //Fill in the vehicle id
    {
        if(GetPlayerSkin(playerid) != 26) //Fill in the skin
        {
            RemovPlayerFromVehicle(playerid);
            SendClientMessage(playerid,0xFF0000FF, "you cant drive this");
        }
    }
    return 1;
}
Thanks for beating a dead horse.