SA-MP Forums Archive
Help phone - 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: Help phone (/showthread.php?tid=537662)



Help phone - ShoortyFl - 16.09.2014

So i've created a script for phone system, and it's not working whenever i enter the right number it shows me the error i don't know what the heck is wrong..
pawn Код:
CMD:call(playerid, params[])
{
    new number, str[250], caller = PI[playerid][PhNumber];
    if(sscanf(params, "d", number)) return SCM(playerid, GREY, "Use: /call [num]");
    foreach(Player, i)
    {
        if(IsPlayerConnected(i))
        {
            if(PI[i][PhNumber] == number)
            {
                if(TalkingWith[i] == 1) return SCM(playerid, TOMATO, " (error) {FFFFFF}This player is already talking with someone !");
                if(InCall[i] == 1) return SCM(playerid, TOMATO, " (error) {FFFFFF}Someone is already calling this player !");
                SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
                Mobile[playerid] = i;
                SCMF(i, WHITE, "Your cellphone is ringing - use '/pickup' to answer, caller: %d", caller);
                format(str, sizeof(str), "* %s's phone is ringing.", PlayerName(i));
                ProxDetector(10.0, playerid, str, PURPLE, PURPLE, PURPLE, PURPLE, PURPLE);
                InCall[i] = 1;
            }
            else
            {
                SCM(playerid, TOMATO, " (error) {FFFFFF}The number you're calling is wrong or currently busy.");
                SetPlayerSpecialAction(playerid,SPECIAL_ACTION_STOPUSECELLPHONE);
                SetPlayerSpecialAction(playerid, 0);
                ClearAnimations(playerid);
                return 1;
            }
        }
    }
    return 1;
}



Re: Help phone - Threshold - 17.09.2014

pawn Код:
CMD:call(playerid, params[])
{
    new number;
    if(sscanf(params, "i", number)) return SCM(playerid, GREY, "Use: /call [number]");
    foreach(new i : Player)
    {
        if(PI[i][PhNumber] == number)
        {
            if(i == playerid) return SCM(playerid, TOMATO, " (error) {FFFFFF}You cannot call yourself !");
            if(TalkingWith[i]) return SCM(playerid, TOMATO, " (error) {FFFFFF}This player is already talking with someone !");
            if(InCall[i]) return SCM(playerid, TOMATO, " (error) {FFFFFF}Someone is already calling this player !");
            SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
            Mobile[playerid] = i;
            SCMF(i, WHITE, "Your cellphone is ringing - use '/pickup' to answer, caller: %d", PI[playerid][PhNumber]);
            new str[50];
            format(str, sizeof(str), "* %s's phone is ringing.", PlayerName(i));
            ProxDetector(10.0, playerid, str, PURPLE, PURPLE, PURPLE, PURPLE, PURPLE);
            InCall[i] = 1;
            return 1;
        }
    }
    SCM(playerid, TOMATO, " (error) {FFFFFF}The number you're calling is wrong or currently busy.");
    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
    SetPlayerSpecialAction(playerid, 0);
    ClearAnimations(playerid);
    return 1;
}
The problem is just the placement of your 'if' and 'else' statements. Technically, if the number didn't match the first player's number (ID 0), then it would give you the error.