SA-MP Forums Archive
Function doesn't work - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Function doesn't work (/showthread.php?tid=156579)



Function doesn't work - kevin974 - 23.06.2010

Код:
public OnVehicleSpawn(vehicleid)
{
  if(IsSmallVehicle(vehicleid)) {
		Vehicle[vehicleid][Fuel] = randomEx(SMALLV_GAS_MIN , SMALLV_GAS_MAX);
	}
	if(IsMidsizeVehicle(vehicleid)) {
		Vehicle[vehicleid][Fuel] = randomEx(MIDV_GAS_MIN, MIDV_GAS_MAX);
	}
	if(IsLargeVehicle(vehicleid)) {
		Vehicle[vehicleid][Fuel] = randomEx(LARGEV_GAS_MIN, LARGEV_GAS_MAX);
	}
	if(IsExLargeVehicle(vehicleid)) {
		Vehicle[vehicleid][Fuel] = randomEx(EXLARGEV_GAS_MIN, EXLARGEV_GAS_MAX);
	}
	
	return true;
}
Well after the cars spawn and i get in them it says there is no gas in the vehicle, But it if change the coding to this it works fine:


Код:
public OnVehicleSpawn(vehicleid)
{
  Vehicle[vehicleid][Fuel] = randomEx(SMALLV_GAS_MIN , SMALLV_GAS_MAX);
  return true;
}
Does anyone know why, if i check to see what car it is first it doesn't set the gas.



Extra functions:
Код:
stock IsSmallVehicle(vehicleid)
{
  switch ( GetVehicleModel(vehicleid)) {
    case 448, 457, 462, 461, 463, 468, 471, 485, 521, 522, 523, 530, 581, 586, 571, 572, 574, 583 : return true;
	}
  return false;
}



Re: Function doesn't work - kevin974 - 23.06.2010

hmm


Re: Function doesn't work - kevin974 - 24.06.2010

kk


Re: Function doesn't work - bigcomfycouch - 24.06.2010

You didn't need a second thread. Did you try what I posted in your other thread?

edit:

Код:
IsSmallVehicle(model)
{
	switch (model)
	{
		case 448, 457, 461 .. 463, 468, 471, 485, 521 .. 523, 530, 581, 586, 571, 572, 574, 583: return 1;
	}
	return 0;
}
replace your callbacks with that format along with what I posted in your other thread


Re: Function doesn't work - kevin974 - 24.06.2010

Yea i tried that, and it still doesnt work.


Re: Function doesn't work - KDlivest954 - 24.06.2010

Код:
public OnVehicleSpawn(vehicleid)
{
  if(IsSmallVehicle(vehicleid)) {
		Vehicle[vehicleid][Fuel] = randomEx(SMALLV_GAS_MIN , SMALLV_GAS_MAX);
	}
	if(IsMidsizeVehicle(vehicleid)) {
		Vehicle[vehicleid][Fuel] = randomEx(MIDV_GAS_MIN, MIDV_GAS_MAX);
	}
	if(IsLargeVehicle(vehicleid)) {
		Vehicle[vehicleid][Fuel] = randomEx(LARGEV_GAS_MIN, LARGEV_GAS_MAX);
	}
	if(IsExLargeVehicle(vehicleid)) {
		Vehicle[vehicleid][Fuel] = randomEx(EXLARGEV_GAS_MIN, EXLARGEV_GAS_MAX);
	}
	
	return true;
}
What if u put else ifs ::
Код:
public OnVehicleSpawn(vehicleid)
{
    if(IsSmallVehicle(vehicleid)) {
		Vehicle[vehicleid][Fuel] = randomEx(SMALLV_GAS_MIN, SMALLV_GAS_MAX);
	}
	else if(IsMidsizeVehicle(vehicleid)) {
		Vehicle[vehicleid][Fuel] = randomEx(MIDV_GAS_MIN, MIDV_GAS_MAX);
	}
	else if(IsLargeVehicle(vehicleid)) {
		Vehicle[vehicleid][Fuel] = randomEx(LARGEV_GAS_MIN, LARGEV_GAS_MAX);
	}
	else if(IsExLargeVehicle(vehicleid)) {
		Vehicle[vehicleid][Fuel] = randomEx(EXLARGEV_GAS_MIN, EXLARGEV_GAS_MAX);
	}
	return true;
}
Im probly rong, but im jus tryna help ;P


Re: Function doesn't work - kevin974 - 24.06.2010

no still doesnt work


Re: Function doesn't work - KDlivest954 - 24.06.2010

why dont you try putting it under OnPlayerEnterVehicle.... wait, then it's jus keep reseting when the player got in, right?


Re: Function doesn't work - KDlivest954 - 24.06.2010

I think this may help:

Код:
public OnVehicleSpawn(vehicleid)
{
  if(IsSmallVehicle(vehicleid) == true) {
		Vehicle[vehicleid][Fuel] = randomEx(SMALLV_GAS_MIN , SMALLV_GAS_MAX);
	}
	if(IsMidsizeVehicle(vehicleid) == true) {
		Vehicle[vehicleid][Fuel] = randomEx(MIDV_GAS_MIN, MIDV_GAS_MAX);
	}
	if(IsLargeVehicle(vehicleid) == true) {
		Vehicle[vehicleid][Fuel] = randomEx(LARGEV_GAS_MIN, LARGEV_GAS_MAX);
	}
	if(IsExLargeVehicle(vehicleid) == true) {
		Vehicle[vehicleid][Fuel] = randomEx(EXLARGEV_GAS_MIN, EXLARGEV_GAS_MAX);
	}
	
	return true;
}
IDK if it would be == true or == 1 tho.


Re: Function doesn't work - bigcomfycouch - 24.06.2010

Код:
if(condition)
and
Код:
if(condition == true)
and
Код:
if(condition == 1)
are all the same thing if the condition is, indeed, true