/locatephone help please...
#1

Hey, I've made this:

pawn Код:
dcmd_locatephone(playerid,params[])
{
    if(PlayerInfo[playerid][pFaction] != 1337) return 1;
    new number;
    if(sscanf(params,"d",number)) return SendClientMessage(playerid,COLOR_GREY,".: Usage: /locatephone [number] :.");
    for(new i=0; i<MAX_PLAYERS; i++)
    {
      if(PlayerInfo[i][pNumber] == number)
      {
            new Float:X, Float:Y, Float:Z;
        GetPlayerPos(i,X,Y,Z);
        SetPlayerCheckpoint(playerid,X,Y,Z,5.0);
            SendClientMessage(playerid,COLOR_GREENLIGHT,".: Info: The Phone has been located :.");
            return 1;
        }
    }
    else SendClientMessage(playerid,COLOR_DARKRED,".: Info: Phone doesn't establish a connection :.");  //<-----------THIS LINE
    return 1;
}
It gives this error:

error 029: invalid expression, assumed zero

on the marked line...


How to solve?

And also, how to put the locate into a timer which updates the marker every second?
Reply
#2

pawn Код:
dcmd_locatephone(playerid,params[])
{
    if(PlayerInfo[playerid][pFaction] != 1337) return 1;
    new number;
    if(sscanf(params,"d",number)) return SendClientMessage(playerid,COLOR_GREY,".: Usage: /locatephone [number] :.");
    for(new i=0; i<MAX_PLAYERS; i++)
    {
      if(PlayerInfo[i][pNumber] == number)
      {
            new Float:X, Float:Y, Float:Z;
        GetPlayerPos(i,X,Y,Z);
        SetPlayerCheckpoint(playerid,X,Y,Z,5.0);
            SendClientMessage(playerid,COLOR_GREENLIGHT,".: Info: The Phone has been located :.");
            return 1;
        }
    else SendClientMessage(playerid,COLOR_DARKRED,".: Info: Phone doesn't establish a connection :.");
    }
    return 1;
}
Doesn't work either because then
This

".: Info: Phone doesn't establish a connection :."

sends like 30 times in the chat =/
Reply
#3

Anyone who can solve this?
Reply
#4

You don't need that else there.

pawn Код:
dcmd_locatephone(playerid,params[])
{
    if(PlayerInfo[playerid][pFaction] != 1337) return 1;
    new number;
    if(sscanf(params,"d",number)) return SendClientMessage(playerid,COLOR_GREY,".: Usage: /locatephone [number] :.");
    for(new i=0; i<MAX_PLAYERS; i++)
    {
      if(PlayerInfo[i][pNumber] == number)
      {
        new Float:X, Float:Y, Float:Z;
        GetPlayerPos(i,X,Y,Z);
        SetPlayerCheckpoint(playerid,X,Y,Z,5.0);
        SendClientMessage(playerid,COLOR_GREENLIGHT,".: Info: The Phone has been located :.");
        return 1;
      }
    }
    SendClientMessage(playerid,COLOR_DARKRED,".: Info: Phone doesn't establish a connection :.");
    return 1;
}
Reply
#5

Quote:
Originally Posted by MadeMan
You don't need that else there.

pawn Код:
dcmd_locatephone(playerid,params[])
{
    if(PlayerInfo[playerid][pFaction] != 1337) return 1;
    new number;
    if(sscanf(params,"d",number)) return SendClientMessage(playerid,COLOR_GREY,".: Usage: /locatephone [number] :.");
    for(new i=0; i<MAX_PLAYERS; i++)
    {
      if(PlayerInfo[i][pNumber] == number)
      {
        new Float:X, Float:Y, Float:Z;
        GetPlayerPos(i,X,Y,Z);
        SetPlayerCheckpoint(playerid,X,Y,Z,5.0);
        SendClientMessage(playerid,COLOR_GREENLIGHT,".: Info: The Phone has been located :.");
        return 1;
      }
    }
    SendClientMessage(playerid,COLOR_DARKRED,".: Info: Phone doesn't establish a connection :.");
    return 1;
}
Thanks man =p...

Can you help me with question 2 aswell?
How to set a timer to update the checkpoint every second? Please =)
Reply
#6

pawn Код:
forward UpdateCheckpoint(playerid, targetid);

public UpdateCheckpoint(playerid, targetid)
{
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(targetid,X,Y,Z);
    DisablePlayerCheckpoint(playerid);
    SetPlayerCheckpoint(playerid,X,Y,Z,5.0);
}
pawn Код:
dcmd_locatephone(playerid,params[])
{
    if(PlayerInfo[playerid][pFaction] != 1337) return 1;
    new number;
    if(sscanf(params,"d",number)) return SendClientMessage(playerid,COLOR_GREY,".: Usage: /locatephone [number] :.");
    for(new i=0; i<MAX_PLAYERS; i++)
    {
      if(PlayerInfo[i][pNumber] == number)
      {
        new Float:X, Float:Y, Float:Z;
        GetPlayerPos(i,X,Y,Z);
        SetPlayerCheckpoint(playerid,X,Y,Z,5.0);
        SetTimerEx("UpdateCheckpoint", 1000, true, "ii", playerid, i); // Add a timer here
        SendClientMessage(playerid,COLOR_GREENLIGHT,".: Info: The Phone has been located :.");
        return 1;
      }
    }
    SendClientMessage(playerid,COLOR_DARKRED,".: Info: Phone doesn't establish a connection :.");
    return 1;
}
Reply
#7

Quote:
Originally Posted by MadeMan
pawn Код:
forward UpdateCheckpoint(playerid, targetid);

public UpdateCheckpoint(playerid, targetid)
{
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(targetid,X,Y,Z);
    DisablePlayerCheckpoint(playerid);
    SetPlayerCheckpoint(playerid,X,Y,Z,5.0);
}
pawn Код:
dcmd_locatephone(playerid,params[])
{
    if(PlayerInfo[playerid][pFaction] != 1337) return 1;
    new number;
    if(sscanf(params,"d",number)) return SendClientMessage(playerid,COLOR_GREY,".: Usage: /locatephone [number] :.");
    for(new i=0; i<MAX_PLAYERS; i++)
    {
      if(PlayerInfo[i][pNumber] == number)
      {
        new Float:X, Float:Y, Float:Z;
        GetPlayerPos(i,X,Y,Z);
        SetPlayerCheckpoint(playerid,X,Y,Z,5.0);
        SetTimerEx("UpdateCheckpoint", 1000, true, "ii", playerid, i); // Add a timer here
        SendClientMessage(playerid,COLOR_GREENLIGHT,".: Info: The Phone has been located :.");
        return 1;
      }
    }


    SendClientMessage(playerid,COLOR_DARKRED,".: Info: Phone doesn't establish a connection :.");
    return 1;
}
I thought of that first but I thought that it would show for both playerid and targetid but then I read closer :P

Thanks =)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)