SA-MP Forums Archive
stock/public 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: stock/public problem (/showthread.php?tid=187863)



stock/public problem - The_Gangstas - 05.11.2010

stocks arent surpose to be used with floats right? cus its returning the floats as 0 for some reason..

stock SetPlayerRouting(playerid, Float1, Float:y1)


Re: stock/public problem - Retardedwolf - 05.11.2010

Nope, floats should be working fine? Post your code.


Re: stock/public problem - The_Gangstas - 05.11.2010

yup tried public.. samp thing

pawn Код:
stock SetPlayerRouting(playerid, Float:x1, Float:y1)
{
    if(IsPlayerInAnyVehicle(playerid) && Gps[playerid] == 1)
    {
        new string[128];
        new textstring[200];
        new Float:x2, Float:y2, Float:z2;
        new Float:angle2;

        GetVehiclePos(GetPlayerVehicleID(playerid), x2, y2, z2);
        GetVehicleZAngle(GetPlayerVehicleID(playerid), angle2);

        new Float:dist;
        dist = floatsqroot(floatpower(floatabs(floatsub(x1,x2)),2)+floatpower(floatabs(floatsub(y1,y2)),2));

        new Float:angle1;
        if( (y1-y2) >= 0.0) angle1 = acos((x1-x2)/dist) - 90;
        else angle1 = 270 - acos((x1-x2)/dist);

        new Float:offset;
        offset = 360.0 - angle2 + angle1;
        if(offset >= 360.0) offset = offset - 360.0;
        else if(offset < 0.0) offset = offset + 360.0;

        if(offset >= 330.0 || offset < 30.0) format(string, sizeof(string), "~u~ ~w~%d ~u~", floatround(dist));
        else if(offset >= 30.0 && offset < 60.0) format(string, sizeof(string), "~<~ ~w~%d", floatround(dist));
        else if(offset >= 60.0 && offset < 100.0) format(string, sizeof(string), "~<~~<~ ~w~%d", floatround(dist));
        else if(offset >= 100.0 && offset < 150.0) format(string, sizeof(string), "~d~~<~ ~w~%d", floatround(dist));
        else if(offset >= 150.0 && offset < 210.0) format(string, sizeof(string), "~d~ ~w~%d ~d~", floatround(dist));
        else if(offset >= 210.0 && offset < 260.0) format(string, sizeof(string), "~w~%d ~>~~d~", floatround(dist));
        else if(offset >= 260.0 && offset < 300.0) format(string, sizeof(string), "~w~%d ~>~~>~", floatround(dist));
        else if(offset >= 300.0 && offset < 330.0) format(string, sizeof(string), "~w~%d ~>~", floatround(dist));
        format(textstring,sizeof(textstring),"~r~Global Positionating System~n~~b~Tracking Coordinates:~w~~n~X %.01f - Y %.01f~n~~n~~p~Distance & Direction:~n~%s", x1, y1, string);
        TextDrawSetString(Textdraw53[playerid],textstring);
        if(floatround(dist) <= 25)
        {
            format(textstring,sizeof(textstring),"~r~Global Positionating System~n~~b~Tracking Coordinates: ~w~~n~X %.01f - Y %.01f~n~~n~~p~Arrived at Position!", x1, y1);
            TextDrawSetString(Textdraw53[playerid],textstring);
        }
        TelePosGps[playerid][tX] = x1;
        TelePosGps[playerid][tY] = y1;
    }
    return 1;
}



Re: stock/public problem - Retardedwolf - 05.11.2010

Well just a tip. You're just updating a player's textdrawstring and not updating/showing it to the player.


Re: stock/public problem - The_Gangstas - 05.11.2010

pawn Код:
enum TelePosEnum
{
   Float:tX,
   Float:tY
};
new Float:TelePosGps[MAX_PLAYERS][TelePosEnum];
        if(IsPlayerInAnyVehicle(i) && PlayerInfo[i][Gps] == 1)
        {
            SetPlayerRouting(i,TelePosGps[i][tX],TelePosGps[i][tY]);
        }
it updates.. i mean dude.. the x and y is always 0

i did
pawn Код:
SetPlayerRouting(playerid, 2234.5054,2452.9285);
and it comes at blueberry 0.0.. the tracking works fine, but its just heading u to 0.0 0.0..


Re: stock/public problem - Retardedwolf - 05.11.2010

Totally got the point wrong. :<(


Re: stock/public problem - The_Gangstas - 05.11.2010

TelePosGps[playerid][tX] = x1;
TelePosGps[playerid][tY] = y1;


Re: stock/public problem - iggy1 - 05.11.2010

try changing to this
pawn Код:
enum TelePosEnum
{
   Float:tX,
   Float:tY
};
new TelePosGps[MAX_PLAYERS][TelePosEnum];
No need to make the variable a float the enum does that for you. As The MAX_PLAYERS part of the variable will be holding an int (playerid).