Some Help To Learn More - 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: Some Help To Learn More (
/showthread.php?tid=357268)
Some Help To Learn More -
Chris1337 - 06.07.2012
Im Now in creating stocks , but im kind of confuse i did this , if anyone can explain me why its not returning nothing (the ґiґ)
pawn Код:
stock nearestwanted(playerid)
{
new Float:x, Float:y, Float:z;
new ii;
GetPlayerPos(playerid, x, y, z);
for( new i = 0; i < MAX_PLAYERS; i++ )
{
if (IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z) && GetPlayerWantedLevel(i) >= 3)
{
printf("Player %d is The Nearest Wanted Level", i);
ii = i;
return i;
}
else
{
printf("No Wanted Level Near");
ii = 0;
return i;
}
}
return ii;
}
my command
pawn Код:
command(wanted, playerid, params[])
{
new string[250];
nearestwanted(playerid);
if(ii > 0)
{
format(string, sizeof(string), "* Nearest Wanted: %s", ii);
SendClientMessage(playerid, -1 ,string);
}
else
{
SendClientMessage(playerid, -1, "No Wanted Level Near");
}
return 1;
}
And my errors are this
pawn Код:
(188) : error 017: undefined symbol "ii"
(190) : error 017: undefined symbol "ii"
pawn Код:
188: if(ii > 0)
{
190: format(string, sizeof(string), "* Nearest Wanted: %s", ii);
SendClientMessage(playerid, -1 ,string);
}
Respuesta: Some Help To Learn More -
Jovanny - 08.07.2012
pawn Код:
command(wanted, playerid, params[])
{
new string[250];
if(nearestwanted(playerid) > 0)
{
format(string, sizeof(string), "* Nearest Wanted: %s", ii);
SendClientMessage(playerid, -1 ,string);
}
else
{
SendClientMessage(playerid, -1, "No Wanted Level Near");
}
return 1;
}
Re: Some Help To Learn More -
Roko_foko - 08.07.2012
You have written the code wrongly. i will correct it and post it here.
EDIT: code
pawn Код:
stock nearestwanted(playerid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
for( new i = 0; i < MAX_PLAYERS; i++ )
{
//if(!IsPlayerConnected(i))continue; // I would add this as well but not that inportant
if (IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z) && GetPlayerWantedLevel(i) >= 3)
{
printf("Player %d is The Nearest Wanted Level", i);
return i;
}
else
{
printf("No Wanted Level Near");
}
}
return -1;
}
pawn Код:
command(wanted, playerid, params[])
{
new string[250];
new Name[MAX_PLAYER_NAME];
new i;
i=nearestwanted(playerid);
if(i >= 0)//playerid can also be 0
{
GetPlayerName(i,Name,sizeof(name));
format(string, sizeof(string), "* Nearest Wanted: [%d]%s", i,Name);
SendClientMessage(playerid, -1 ,string);
}
else
{
SendClientMessage(playerid, -1, "No Wanted Level Near");
}
return 1;
}