IsPlayerInVehicle??
#1

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;
}
Reply
#2

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)