SA-MP Forums Archive
IsPlayerInVehicle?? - 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: IsPlayerInVehicle?? (/showthread.php?tid=324001)



IsPlayerInVehicle?? - Hudgens - 07.03.2012

Trying to make a carscrap point, where I'll receive a certain amount of money for this car.
But when I'm at the point, it just says You are not in a car, which would indicate that I wasn't in the slamvan, but I am, and I'm at the point. Yet I do not receive any money, why? I can't see what's wrong in the code.
Код:
 	if(strcmp("/carscrap", cmdtext, true, 10) == 0)
 	 {
    if(IsPlayerInRangeOfPoint(playerid, 3.0, 2690.7373,-2225.6082,13.3106)) {
    if(IsPlayerInVehicle(playerid, 535)){
    GivePlayerMoney(playerid, 2000);
    SendClientMessage(playerid, COLOR_YELLOW, "You've received 2000 bucks for scrapping this car");
    } else{
  	SendClientMessage(playerid, COLOR_YELLOW, "You are not in a car");
 	}
  	} else {
    SendClientMessage(playerid, COLOR_YELLOW, "You are not at the scrap point");
	}
 	return 1;
 	}
 	return 0;
}



Re: IsPlayerInVehicle?? - IstuntmanI - 07.03.2012

Try this:
Код:
if(strcmp(cmdtext, "/carscrap", cmdtext, true) == 0)
{
	if(IsPlayerInRangeOfPoint(playerid, 10.0, 2690.7373,-2225.6082,13.3106)) 
		return SendClientMessage(playerid, COLOR_YELLOW, "You are not at the scrap point");

	if(IsPlayerInVehicle(playerid, 535))
		return SendClientMessage(playerid, COLOR_YELLOW, "You are not in the scrap car");

	GivePlayerMoney(playerid, 2000);
	SendClientMessage(playerid, COLOR_YELLOW, "You've received 2000 bucks for scrapping this car");
	return 1;
}
I increased the range and improved the code. With IsPlayerInVehicle 535 you must to be in vehicle ID 535, to use for vehicle model use
Код:
if(strcmp(cmdtext, "/carscrap", cmdtext, true) == 0)
{
	if(IsPlayerInRangeOfPoint(playerid, 10.0, 2690.7373,-2225.6082,13.3106)) 
		return SendClientMessage(playerid, COLOR_YELLOW, "You are not at the scrap point");

	if(GetVehicleModel(GetPlayerVehicleID(playerid) == 535)
		return SendClientMessage(playerid, COLOR_YELLOW, "You are not in the scrap car");

	GivePlayerMoney(playerid, 2000);
	SendClientMessage(playerid, COLOR_YELLOW, "You've received 2000 bucks for scrapping this car");
	return 1;
}