How can I make a simple phone system?
#1

Hi there. I recently started developing my server and it's come to the point to adding different things. I noticed I didn't do a phone system yet, but hence I'm a new scripter, I have no idea how to. I already included "Cellphone" and "Cellnumber" in the pInfo, but now I was wondering how I could make it work? I only require a simple /call, /hangup and /togphone(?). Help'd be greatly appreciated and I wouldn't mind giving whoever helped me reputation for it.
Reply
#2

Bump.
Reply
#3

https://sampforum.blast.hk/showthread.php?tid=154340 look here!

or https://sampforum.blast.hk/showthread.php?tid=294695

OR https://sampforum.blast.hk/showthread.php?pid=1822095#pid1822095
Reply
#4

pawn Code:
new
    bool:   PhoneOffline [ MAX_PLAYERS ] = false,
            PhoneInACall [ MAX_PLAYERS ] = -1,
            PhoneRequestingCall [ MAX_PLAYERS ] = -1;
   
CMD:togphone( playerid, params[] )
{
    if( PhoneOffline [ playerid ] == false )
    {
        PhoneOffline [ playerid ] = true;
        SendClientMessage( playerid, -1, "* Phone offline!" );
    }
    else
    {
        PhoneOffline [ playerid ] = false;
        SendClientMessage( playerid, -1, "* Phone online!" );
    }
    return true;
}

CMD:call( playerid, params[] )
{
    new
        num,
        numbermatches = 0;

    if( sscanf( params, "i", num ) )
        return SendClientMessage( playerid, Colour_RankOrange, "HELP: "#Int_White"/call [ phone number ]" );

    for( new u; u < MAX_PLAYERS; u ++ )
    {
        if( plStats [ u ] [ CellPhoneNumber ] == num )
        {
            cell_RequestingCall [ playerid ] = u;
            cell_RequestingCall [ u ] = u;

            SendClientMessage( playerid, -1, "* Ringing.." );
            numbermatches ++;
        }
    }

    if( numbermatches == 0 )
        return ShowPlayerErrorMessage( playerid, "That number seems to be disconnected!" );
    return true;
}

CMD:answer( playerid, params[] )
{
    if( cell_InACall [ playerid ] == -1 && cell_RequestingCall [ playerid ] != -1 )
    {
        for( new u; u < MAX_PLAYERS; u ++ )
        {
            if( cell_RequestingCall [ playerid ] == cell_RequestingCall [ u ] )
            {
                cell_InACall [ playerid ] = cell_RequestingCall [ playerid ];
                cell_InACall [ u ] = cell_InACall [ playerid ];

                SendClientMessage( u, -1, "* Call connected." );
                SendClientMessage( playerid, -1, "* Call connected." );
            }
        }
    }
    else return ShowPlayerErrorMessage( playerid, "You're already in a call!" );
    return true;
}

CMD:hangup( playerid, params[] )
{
    for( new u; u < MAX_PLAYERS; u ++ )
    {
        if( cell_InACall [ playerid ] == cell_InACall [ u ] )
        {
            SendClientMessage( u, -1, "* They hung up!" );
        }
    }
    cell_InACall [ playerid ] = -1;
    cell_RequestingCall [ playerid ] = -1;
    return true;
}

public OnPlayerText(playerid, text[])
{
    new
        cStr [ 128 ];

    if( cell_InACall [ playerid ] != -1 )
    {
        for( new u; u < MAX_PLAYERS; u ++ )
        {
            if( cell_InACall [ playerid ] == cell_InACall [ u ] )
            {
                format( cStr, 128, ""#Int_RankOrange"Cellphone: "#Int_White"%s (( %s ))", text, GetPlayerNameEx( playerid ) );

                SendClientMessage( u, -1, cStr );
            }
        }
        return false;
    }
    return true;
}
Here's an example of how I made mine. The togphone is just copy-pasteable, but the others you're going to have to modify.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)