Command Help.
#1

Hello, i'm new in scripting, and i need some help, i have vehicle and dealership system with /engine command, its working fine but the player can engine any car not matter if its owned or not, so i need someone to help me and make it just if its owned,
if somone tried to engine not owned car type " you don't have the keys of this vehicle ", and if he is the owner of the car he can engine it.

Thanks for helping.
Reply
#2

What's the method of determining ownership? For a variable it's as simple as:

pawn Код:
if([variable] == [not owned]) return SendClientMessage(playerid, color, "You don't have the keys of this vehicle");
We can't help you further without seeing the command itself.
Reply
#3

here is :

Код:
CMD:engine(playerid, params[])
{
    new engine, lights, alarm, doors, bonnet, boot, objective, vehicleid, string[128];
   	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
	if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You are not driving a vehicle.");
	if(vehicleid == 509 || vehicleid == 481 || vehicleid == 510) return SendClientMessage(playerid, COLOR_GREY, "Bicycles have no engine.");
	vehicleid = GetPlayerVehicleID(playerid);
	GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
	if(!engine)
	{
	    SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
	    if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVeh])
	    {SetVehicleParamsEx(vehicleid, 1, lights, alarm, PlayerInfo[playerid][vLocked], bonnet, boot, objective);}
	    else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVVeh])
	    {SetVehicleParamsEx(vehicleid, 1, lights, alarm, PlayerInfo[playerid][vVLocked], bonnet, boot, objective);}
	    else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pBVeh])
	    {SetVehicleParamsEx(vehicleid, 1, lights, alarm, PlayerInfo[playerid][vBLocked], bonnet, boot, objective);}
 		format(string, sizeof(string), "* %s turns the key's engine on.", RPN(playerid));
		if(PlayerInfo[playerid][pMaskOn] == 1)
		{
	        format(string, sizeof(string), "* Stranger turns the vehicle's engine on.");
		}
		else
		{
			format(string, sizeof(string), "* %s turns the vehicle's engine on.", RPN(playerid));
		}
 		SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
	}
	else
	{
	    SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective);
	    if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVeh])
	    {SetVehicleParamsEx(vehicleid, 0, lights, alarm, PlayerInfo[playerid][vLocked], bonnet, boot, objective);}
	    if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVVeh])
	    {SetVehicleParamsEx(vehicleid, 0, lights, alarm, PlayerInfo[playerid][vVLocked], bonnet, boot, objective);}
	    if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pBVeh])
	    {SetVehicleParamsEx(vehicleid, 0, lights, alarm, PlayerInfo[playerid][vBLocked], bonnet, boot, objective);}
	    format(string, sizeof(string), "* %s turns the vehicle's engine off.", RPN(playerid));
 		if(PlayerInfo[playerid][pMaskOn] == 1)
		{
	        format(string, sizeof(string), "* Stranger turns the vehicle's engine off.");
		}
		else
		{
			format(string, sizeof(string), "* %s turns the vehicle's engine off.", RPN(playerid));
		}
 		SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
	}
	return 1;
}
Reply
#4

That still doesn't show us what variable stores who owns the vehicle. If it's just a simple global variable it's as easy as:

if(vOwner[vehicleid] != playerid) return SendClientMessage(playerid, COLOR_WHITE, "You don't have the keys to this vehicle.");
Reply
#5

i added this to my /engine command, you think it will work?

Код:
	if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVVeh])
	{
		SendClientMessage(playerid, COLOR_GREEN, " You don't have the keys of this vehicle.");
	}
	else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pBVeh])
	{
		SendClientMessage(playerid, COLOR_GREEN, " You don't have the keys of this vehicle.");
	}
		else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVeh])
	{
	SendClientMessage(playerid, COLOR_GREEN, " You don't have the keys of this vehicle.");
	}
	return 1;
}
Reply
#6

when i enter to my car and try to /engine it, they say "You don't have the keys of this vehicle.", i need it to unowned vehicle, and there is another bug, they say "You don't have they keys and its turn on normal.

Anyone can help?
Reply
#7

What you're doing is checking if the player owns the vehicle, and if the player does, you're telling him it's not his vehicle. You're close.

pawn Код:
if(GetPlayerVehicleID(playerid) != PlayerInfo[playerid][pVVeh] &&
GetPlayerVehicleID(playerid) != PlayerInfo[playerid][pBVeh] &&
GetPlayerVehicleID(playerid) != PlayerInfo[playerid][pVeh]) {
    return SendClientMessage(playerid, COLOR_GREEN, " You don't have the keys of this vehicle.");
}
That checks is [player's vehicle] is NOT [pVVeh], AND is NOT [pBVeh], AND is NOT [pVeh]. If any of those statements are true (if the player owns any of those vehicles) the command will continue, if not then it will return [end the command] by sending them the message.
Reply
#8

Zezombia's code should work for you. == is the same a equal, so what you did was if the player's pveh is equal to the vehicleid it sends the message.
!= means it's not equal. putting ! before makes it return the oposite.
Reply
#9

its worked, when i try to engine my car they say nothing, but if i tried to engine someone's car they show "You don't have the keys of this vehicle" but, i can engine it, i need if i tried to engine someone's car they say " you don't have the keys of this vehicle" and the engine still off.
can you help me with this?
Reply
#10

Okay, i took this code from /engine command and its when you engineoff ur car, i did if you tried to engine your own car you can't engine it, and you can engine unowned cars, i need you can engine just ur own car, not unowned, i hope this code will help you.

Код:
   if(GetPlayerVehicleID(playerid) != PlayerInfo[playerid][pVVeh] &&
    GetPlayerVehicleID(playerid) != PlayerInfo[playerid][pBVeh] &&
    GetPlayerVehicleID(playerid) != PlayerInfo[playerid][pVeh]) {
    return SendClientMessage(playerid, COLOR_GREEN, " You don't have the keys of this vehicle.");
	}
	else
	{
	    if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVeh])
	    {
		SetVehicleParamsEx(vehicleid, 0, lights, alarm, PlayerInfo[playerid][vLocked], bonnet, boot, objective);
		}
	    if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVVeh])
	    {
		SetVehicleParamsEx(vehicleid, 0, lights, alarm, PlayerInfo[playerid][vLocked], bonnet, boot, objective);
		}
	    if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pBVeh])
	    {
		SetVehicleParamsEx(vehicleid, 0, lights, alarm, PlayerInfo[playerid][vLocked], bonnet, boot, objective);
	    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)