Can someone tell me what it is ( _: )
#1

Hey can someone tell me what _: use for?
Reply
#2

Depends on your script i guess?
Show where you've seen it or something, then we might be able to tell you.
Reply
#3

I've used that in a stock to get the distance between 2 players:

pawn Код:
stock GetDistance(playerid, targetid)
{
    new Float:tX, Float:tY, Float:tZ, Float:distance;
    GetPlayerPos(targetid, tX, tY, tZ), distance = GetPlayerDistanceFromPoint(playerid, tX, tY, tZ);
    return _:distance;
}
So I guess it returns floats?
Reply
#4

No, it doesn't return floats. Normally you would have to define that function as:
pawn Код:
stock Float:GetDistance(playerid, targetid)
Then you just 'return distance;', but '_:' lets the compiler determine the nature of the variable, whether it's a float or integer etc.

I'm not 100% sure, but I know that it allows you to treat floats as integers technically speaking... I'm probably not wording this right, but hopefully there's someone that can give you a better explanation.
Reply
#5

"_:" is used to eliminate pawno 213 warning.

pawn Код:
new Text3D:Forks; printf("%i", Forks); //tag mismatch
pawn Код:
new Text3D:Forks; printf("%i",_:Forks); //smooth
Reply
#6

It's a tag override. It basically removes the tag of a variable if it has one. This is mostly used to get rid "argument type mismatch" warnings when variables with non-standard tags (e.g. Text:, Db_result:, ...) are passed to functions like format or CallLocalFunction.

If you look up the definition of those two functions you will notice that it has a parameter:
Код:
{Float,_}:...
This means that it accepts variables that are either Float or have no tag. Trying to pass any of the types mentioned above will result in a warning.
Reply
#7

Ok thank's all, now i understood +Rep for all
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)