SA-MP Forums Archive
Public isnt working - 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: Public isnt working (/showthread.php?tid=216904)



Public isnt working - Ice-cup - 26.01.2011

Код:
public IsVehicleInRadius(playerid)
{
	for(new c=0;c<MAX_VEHICLES;c++)
	{
	    new Float:x, Float:y, Float:z;
		GetVehiclePos(c,x,y,z);
		if(5.0, playerid, x, y, z)
		{
		    return 1;
		}
		else
		{
		    SendClientMessage(playerid, COLOR_YELLOW, "You're not at your car!");
		    return 1;
		}
	}
	return 1;
}
Gets me "Youre not at your car" even tho I am ON my vehicle..


Re: Public isnt working - [WF]Demon - 26.01.2011

pawn Код:
public IsVehicleInRadius(playerid)
{
    for(new c=0;c<MAX_VEHICLES;c++)
    {
        new Float:x, Float:y, Float:z;
        GetVehiclePos(c,x,y,z);
        if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
        {
            return SendClientMessage(playerid, COLOR_YELLOW, "You're at your car!");
        }
        else
        {
            return SendClientMessage(playerid, COLOR_YELLOW, "You're not at your car!");
        }
    }
    return 1;
}
UNTESTED


Re: Public isnt working - Vince - 26.01.2011

pawn Код:
if(5.0, playerid, x, y, z)
Does that even compile?

pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
Edit: Too late


Re: Public isnt working - Gabe - 26.01.2011

GetVehiclePos(c,x,y,z); returns a finite position, you need to use a GetDistanceFromPlayer(5.0, playerid, x, y, z) function or the like.

EDIT: Also too late.


Re: Public isnt working - Ice-cup - 26.01.2011

Код:
public IsVehicleInRadius(playerid)
{
	for(new c=0;c<MAX_VEHICLES;c++)
	{
	    new Float:x, Float:y, Float:z;
		GetVehiclePos(c,x,y,z);
		if(PlayerToPoint(5.0, playerid, x, y, z))
		{
		    return 1;
		}
		else
		{
		    SendClientMessage(playerid, COLOR_YELLOW, "You're not at your car!");
		    return 1;
		}
	}
	return 1;
}
Ye I have the PlayerToPoint function, still doesn't work though.

It is called at:

Код:
		else if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
		{
      		GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
			if(doors == 0)
			{
   				if(IsVehicleInRadius(playerid))
			    {
   		    		if(PlayerInfo[playerid][pCar] == DynamicCars[VehicleLockedPlayer[playerid]][CarID])
   		    		{
						if(PlayerInfo[playerid][pSex] == 1)
						{
							PlayerActionMessage(playerid,15.0,"has just unlocked his vehicle.");
						}
						else
						{
							PlayerActionMessage(playerid,15.0,"has just unlocked her vehicle.");
						}
						SendClientMessage(playerid,COLOR_LIGHTYELLOW2,"[INFO:] Vehicle Unlocked.");
						SetVehicleParamsEx(carid,VEHICLE_PARAMS_OFF,VEHICLE_PARAMS_OFF,VEHICLE_PARAMS_OFF,VEHICLE_PARAMS_OFF,VEHICLE_PARAMS_OFF,VEHICLE_PARAMS_OFF,VEHICLE_PARAMS_OFF);
					}
					else
					{
					    SendClientMessage(playerid, COLOR_RED, "You do not have the keys for this vehicle!");
					}
			    }
			}
			else
			{
   				if(IsVehicleInRadius(playerid))
			    {
   		    		if(PlayerInfo[playerid][pCar] == DynamicCars[VehicleLockedPlayer[playerid]][CarID])
   		    		{
						if(PlayerInfo[playerid][pSex] == 1)
						{
							PlayerActionMessage(playerid,15.0,"has just locked his vehicle.");
						}
						else
						{
							PlayerActionMessage(playerid,15.0,"has just locked her vehicle.");
						}
						SendClientMessage(playerid,COLOR_LIGHTYELLOW2,"[INFO:] Vehicle locked.");
						SetVehicleParamsEx(carid,VEHICLE_PARAMS_OFF,VEHICLE_PARAMS_OFF,VEHICLE_PARAMS_OFF,VEHICLE_PARAMS_ON,VEHICLE_PARAMS_OFF,VEHICLE_PARAMS_OFF,VEHICLE_PARAMS_OFF);
					}
					else
					{
					    SendClientMessage(playerid, COLOR_RED, "You do not have the keys for this vehicle!");
					}
				}
			}
  		}
But yeh, if it doesn't passes the own-made public it goes nowhere:P