Get PVar problem - 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: Get PVar problem (
/showthread.php?tid=523487)
Get PVar problem -
cnoopers - 02.07.2014
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)
Re: Get PVar problem -
Konstantinos - 02.07.2014
https://sampwiki.blast.hk/wiki/Function:GetVehiclePos
The x, y, z coordinates are passed by reference.
Re: Get PVar problem -
cnoopers - 02.07.2014
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
Re: Get PVar problem -
Konstantinos - 02.07.2014
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.