Some Help To Learn More
#1

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)