Phone script... Need help.
#1

Hey, I've tried to make this /c [number] to work...

When I type /c and a number which is available, it says it's not.

pawn Код:
dcmd_c(playerid,params[])
{
    new string[128],number,pName[MAX_PLAYER_NAME],idName[MAX_PLAYER_NAME],proxp[128],proxid[128];
    GetPlayerName(playerid,pName,sizeof(pName));
    if(sscanf(params,"d",number)) return SendClientMessage(playerid,COLOR_GREY,".: Usage: /c [number] :.");
    Sextext(playerid);
    format(proxp,128,"%s uses %s cellphone",pName,Sex);
    ProxDetector(10.0,playerid,proxp,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    SetPlayerSpecialAction(playerid,SPECIAL_ACTION_USECELLPHONE);
    if(PlayerInfo[playerid][pCellphone] == 0) return SendClientMessage(playerid,COLOR_DARKRED,".: Info: You don't have a cellphone :.");
    for(new i=0; i<MAX_PLAYERS; i++)
    {
      if(PlayerInfo[i][pCellphone] != number)
        {
            SendClientMessage(playerid,COLOR_DARKRED,".: Info: Call initiated, \"Number not available\" :.");
            PlayerInfo[playerid][pOncall] = 1;
            return 1;
        }
        if(PlayerInfo[i][pCellphone] == number)
        {
          GetPlayerName(i,idName,sizeof(idName));
          PlayerInfo[i][pCalling] = playerid;
          PlayerInfo[playerid][pCalling] = i;
          format(string,128,".: Info: Number %d is calling :.",PlayerInfo[playerid][pCellphone]);
          format(proxid,128,"%s's phone is sounding",idName);
            SendClientMessage(i,COLOR_YELLOW,string);
            ProxDetector(10.0,i,proxid,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        }
    }
    return 1;
}
Help please =)
Reply
#2

Quote:
Originally Posted by Seif_
Use printf() to debug.
huh?

don't understand, sorry...
Reply
#3

Quote:
Originally Posted by IntrozeN
huh?

don't understand, sorry...
He meant: use the printf function (debug messages) to see where the problem is.
Reply
#4

Quote:
Originally Posted by Don Correlli
Quote:
Originally Posted by IntrozeN
huh?

don't understand, sorry...
He meant: use the printf function (debug messages) to see where the problem is.
how?

print a message after each thing the command checks?
Reply
#5

Yes, after each function/statement.
Reply
#6

pawn Код:
dcmd_c(playerid,params[])
{
    new string[128],number,pName[MAX_PLAYER_NAME],idName[MAX_PLAYER_NAME],proxp[128],proxid[128];
    GetPlayerName(playerid,pName,sizeof(pName));
    print("playerid name gotten");
    if(sscanf(params,"d",number)) return SendClientMessage(playerid,COLOR_GREY,".: Usage: /c [number] :.");
    print("sscanf done");
    Sextext(playerid);
    print("sextext checked");
    format(proxp,128,"%s uses %s cellphone",pName,Sex);
    ProxDetector(10.0,playerid,proxp,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    print("proxdetector sent");
    SetPlayerSpecialAction(playerid,SPECIAL_ACTION_USECELLPHONE);
    print("special action preformed");
    if(PlayerInfo[playerid][pCellphone] == 0) return SendClientMessage(playerid,COLOR_DARKRED,".: Info: You don't have a cellphone :.");
    print("cellphone checked");
    for(new i=0; i<MAX_PLAYERS; i++)
    {
      if(PlayerInfo[i][pCellphone] != number)
        {
            SendClientMessage(playerid,COLOR_DARKRED,".: Info: Call initiated, \"Number not available\" :.");
            PlayerInfo[playerid][pOncall] = 1;
            print("no one had the number");
            return 1;
        }
        if(PlayerInfo[i][pCellphone] == number)
        {
          print("someone had the number");
          GetPlayerName(i,idName,sizeof(idName));
          PlayerInfo[i][pCalling] = playerid;
          PlayerInfo[playerid][pCalling] = i;
          format(string,128,".: Info: Number %d is calling :.",PlayerInfo[playerid][pCellphone]);
          format(proxid,128,"%s's phone is sounding",idName);
            SendClientMessage(i,COLOR_YELLOW,string);
            ProxDetector(10.0,i,proxid,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        }
    }
    return 1;
}
Checked, it fails here:
pawn Код:
if(PlayerInfo[i][pCellphone] != number)
It thinks no one has the number but infact, someone has.

How to solve?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)