errors - 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: errors (
/showthread.php?tid=601300)
errors -
Karolukas123 - 19.02.2016
Код:
warning 209: function "GetPlayerTheoreticAngle" should return a value
error 010: invalid function or declaration
}
//Float:GetPlayerTheoreticAngle(playerid)
stock GetPlayerTheoreticAngle(playerid)
{
new Float:MindAngle = 0.0, Float:angle2 = 0.0;
if(IsPlayerConnected(playerid))
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
new Float:dis = floatsqroot(floatpower(floatabs(floatsub(x, Drifting[playerid][pPos][0])), 2)+floatpower(floatabs(floatsub(y, Drifting[playerid][pPos][1])), 2));
if(IsPlayerInAnyVehicle(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), angle2);
else GetPlayerFacingAngle(playerid, angle2);
if(Drifting[playerid][pPos][0] >= x)
{
new Float:tmp = (x >= Drifting[playerid][pPos][0]) ? (x - Drifting[playerid][pPos][0]) : (Drifting[playerid][pPos][0] - x), Float:sin = asin(tmp / dis);
if(Drifting[playerid][pPos][1] >= y) MindAngle = floatadd(floatsub(floatadd(sin, 90), floatmul(sin, 2)), 90.0);
else MindAngle = floatsub(floatadd(sin, 180), 180.0);
}
else
{
if(Drifting[playerid][pPos][1] < y)
{
new Float:tmp2 = (y >= Drifting[playerid][pPos][1]) ? (y - Drifting[playerid][pPos][1]) : (Drifting[playerid][pPos][1] - y), Float:sin = acos(tmp2 / dis);
MindAngle = floatsub(floatadd(sin, 360), floatmul(sin, 2));
}
else
{
new Float:tmp = (x >= Drifting[playerid][pPos][0]) ? (x - Drifting[playerid][pPos][0]) : (Drifting[playerid][pPos][0] - x), Float:sin = asin(tmp / dis);
MindAngle = floatadd(sin, 180);
}
}
}
}
return (!MindAngle) ? (angle2) : (MindAngle);
Re: errors -
nezo2001 - 19.02.2016
PHP код:
stock GetPlayerTheoreticAngle(playerid)
{
new Float:MindAngle = 0.0, Float:angle2 = 0.0;
if(IsPlayerConnected(playerid))
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
new Float:dis = floatsqroot(floatpower(floatabs(floatsub(x, Drifting[playerid][pPos][0])), 2)+floatpower(floatabs(floatsub(y, Drifting[playerid][pPos][1])), 2));
if(IsPlayerInAnyVehicle(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), angle2);
else GetPlayerFacingAngle(playerid, angle2);
if(Drifting[playerid][pPos][0] >= x)
{
new Float:tmp = (x >= Drifting[playerid][pPos][0]) ? (x - Drifting[playerid][pPos][0]) : (Drifting[playerid][pPos][0] - x), Float:sin = asin(tmp / dis);
if(Drifting[playerid][pPos][1] >= y) MindAngle = floatadd(floatsub(floatadd(sin, 90), floatmul(sin, 2)), 90.0);
else MindAngle = floatsub(floatadd(sin, 180), 180.0);
}
else
{
if(Drifting[playerid][pPos][1] < y)
{
new Float:tmp2 = (y >= Drifting[playerid][pPos][1]) ? (y - Drifting[playerid][pPos][1]) : (Drifting[playerid][pPos][1] - y), Float:sin = acos(tmp2 / dis);
MindAngle = floatsub(floatadd(sin, 360), floatmul(sin, 2));
}
else
{
new Float:tmp = (x >= Drifting[playerid][pPos][0]) ? (x - Drifting[playerid][pPos][0]) : (Drifting[playerid][pPos][0] - x), Float:sin = asin(tmp / dis);
MindAngle = floatadd(sin, 180);
}
}
}
return (!MindAngle) ? (angle2) : (MindAngle);
}
Re: errors -
Karolukas123 - 19.02.2016
its work but know.. return (!MindAngle) ? (angle2) : (MindAngle); warning 213: tag mismatch
Re: errors -
Vince - 19.02.2016
If you return a floating point value then the function itself must also be declared with a Float: tag.
Re: errors -
Karolukas123 - 19.02.2016
but its float
new Float:MindAngle = 0.0, Float:angle2 = 0.0;
Re: errors -
Trucido - 19.02.2016
hes talking about this
Код:
stock GetPlayerTheoreticAngle(playerid)
should be
Код:
stock Float:GetPlayerTheoreticAngle(playerid)
or w/e
Re: errors -
Karolukas123 - 20.02.2016
if i use
Код:
stock Float:GetPlayerTheoreticAngle(playerid)
function with tag result used before definition, forcing reparse
ohh i fix it.. thanks all for help