SA-MP Forums Archive
Phone script... Need help. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Phone script... Need help. (/showthread.php?tid=106100)



Phone script... Need help. - introzen - 01.11.2009

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 =)


Re: Phone script... Need help. - introzen - 01.11.2009

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

don't understand, sorry...


Re: Phone script... Need help. - Correlli - 01.11.2009

Quote:
Originally Posted by IntrozeN
huh?

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


Re: Phone script... Need help. - introzen - 01.11.2009

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?


Re: Phone script... Need help. - Correlli - 01.11.2009

Yes, after each function/statement.


Re: Phone script... Need help. - introzen - 01.11.2009

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?