stock/public problem
#1

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)
Reply
#2

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

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;
}
Reply
#4

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

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..
Reply
#6

Totally got the point wrong. :<(
Reply
#7

TelePosGps[playerid][tX] = x1;
TelePosGps[playerid][tY] = y1;
Reply
#8

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).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)