Get PVar problem
#1

when player enter pickup:
Код:
SetPVarInt(playerid, "playersveh", vehicleid);
get pvar when player press key if player is in pickup
Код:
if(GetVehiclePos(GetPVarInt(playerid, "playersveh"), 2180.6826, -1911.3473, 12.5025)) //error 035: argument type mismatch (argument 2)
Reply
#2

https://sampwiki.blast.hk/wiki/Function:GetVehiclePos

The x, y, z coordinates are passed by reference.
Reply
#3

aww yeah i got that but not work
Код:
	if(pickupid == carrepairpickup1)
	{
	    if(IsPlayerInAnyVehicle(playerid))
	    {
/*	        if(GetRepairPrice(vehicleid, fixprice) >= 1)
	        {
	            SendClientMessage(playerid, COLOR_GREY, "You don't have to repair that car!");
	        }else{*/
				format(string, sizeof(string), "Press Y to repair car for $%i", GetRepairPrice(vehicleid, fixprice));
				SendClientMessage(playerid, COLOR_GREY, string);
				SetPVarInt(playerid, "fixprice", GetRepairPrice(vehicleid, fixprice));
				SetPVarInt(playerid, "playersveh", vehicleid);
//			}
	    }
	}
Код:
	if(PRESSED(KEY_YES))
	{
	    new Float:x, Float:y, Float:z;
	    new Float:x2, Float:y2, Float:z2;
	    GetVehiclePos(GetPVarInt(playerid, "playersveh"), x, y, z);
	    if(x == 2180.6826) /*carrepairpickup1 position*/ if(y == -1911.3473) if(z == 12.5025) //2180.6826, -1911.3473, 12.5025
	    {
  			if(GetMoney(playerid) >= GetPVarInt(playerid, "fixprice"))
			{
			    GiveMoney(playerid, -GetPVarInt(playerid, "fixprice"));
			    RepairVehicle(GetPVarInt(playerid, "playersveh"));
			    GetVehiclePos(GetPVarInt(playerid, "playersveh"), x2, y2, z2);
			    SetVehiclePos(GetPVarInt(playerid, "playersveh"), x2, y2, z2+1);
			}
	    }
	}
somes gotta be wrong with pvars
Reply
#4

Don't compare floating-point numbers like that because some values go off. Use operators (>, <, >=, <= etc) but I believe you want to check if the vehicle is close to a place so GetVehicleDistanceFromPoint would be useful.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)