SA-MP Forums Archive
Help Warning - 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: Help Warning (/showthread.php?tid=569911)



Help Warning - KingPersona - 03.04.2015

i added stock "SetPosInFrontOfPlayer"


no problem with this i added
Код:
SetPPos(playerid,Float:X,Float:Y,Float:Z) return TeleportTime[playerid] = 5,SetPlayerPos(playerid,X,Y,Z);

stock SetPosInFrontOfPlayer(playerid,giveplayerid,Float:distance)
{
	new Float:x,Float:y,Float:z,Float:a;
	GetPlayerPos(playerid, x, y,z); GetPlayerFacingAngle(playerid, a);
	x += (distance * floatsin(-a, degrees));
	y += (distance * floatcos(-a, degrees));
	SetPPos(giveplayerid,x,y,z); SetPlayerFacingAngle(giveplayerid,a);
	return true;
}
and i get warning in this stock , i was not geted warning before
pawn Код:
Float:Distance
this line
Full code
pawn Код:
stock GetClosestPlayer(const playerid) {
    new
        Float:Distance,
        target = -1;

    foreach(Player, i) {
        if (playerid != i && playerVariables[i][pSpectating] == INVALID_PLAYER_ID && (target < 0 || Distance > GetDistanceBetweenPlayers(playerid, i))) {
            target = i;
            Distance = GetDistanceBetweenPlayers(playerid, i);
        }
    }
    return target;
}



Re: Help Warning - KingPersona - 03.04.2015

bump!


Re: Help Warning - Evocator - 03.04.2015

Becuase you have a "Distance" stock somewhere around ur script...

Код:
//==============================================================================
stock GetClosestPlayer(playerid)
{
	if (!IsPlayerConnected(playerid)) return 0;

	new Float:cdist, targetid = -1;
	foreach (new i : Player)
	{
	    if (GetPlayerState(i) == PLAYER_STATE_SPECTATING) continue;
	    if (playerid == i) continue;

		if (targetid < 0 || cdist > GetDistanceBetweenPlayers(playerid, i))
		{
	  		targetid = i;
	  		cdist = GetDistanceBetweenPlayers(playerid, i);
		}
	}
	return targetid;
}



Re: Help Warning - KingPersona - 04.04.2015

Quote:
Originally Posted by Ralfie
Посмотреть сообщение
Becuase you have a "Distance" stock somewhere around ur script...

Код:
//==============================================================================
stock GetClosestPlayer(playerid)
{
	if (!IsPlayerConnected(playerid)) return 0;

	new Float:cdist, targetid = -1;
	foreach (new i : Player)
	{
	    if (GetPlayerState(i) == PLAYER_STATE_SPECTATING) continue;
	    if (playerid == i) continue;

		if (targetid < 0 || cdist > GetDistanceBetweenPlayers(playerid, i))
		{
	  		targetid = i;
	  		cdist = GetDistanceBetweenPlayers(playerid, i);
		}
	}
	return targetid;
}
Thanks for Reply and ur Help

i tryed it
i get errors =(

Код:
(7537) : error 017: undefined symbol "foreach"
7537) : error 029: invalid expression, assumed zero
(7537) : error 017: undefined symbol "i"
(7537) : fatal error 107: too many error messages on one line



Re: Help Warning - KingPersona - 04.04.2015

Bump! Urgent.


Re: Help Warning - CalvinC - 04.04.2015

If you don't have foreach, use a normal player loop.
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i ++)
{
    if(IsPlayerConnected(i))
    {
        // Code
    }
}
Or just download it, it's faster and easier to use than plain player loops.