cellphone audio
#1

This is my /call command and I want to pay the audio like in single players when someone calls CJ, if you know what I mean. When I receive a call I will listen the audio and when I /pickup the audio will stop. I will REP++

PHP код:
CMD:call(playeridparams[])
{
    new 
string[128], phonenumb;
    if(
isnull(params))
        return 
SendClientMessage(playeridCOLOR_WHITE"USAGE: /call [phonenumber]");
    
phonenumb strval(params);
    if(
PlayerInfo[playerid][pNumber] == 0)
    {
        
SendClientMessage(playeridCOLOR_WHITE"You don't have a cell phone.");
        return 
1;
    }
    if(
PhoneOnline[playerid] > 0)
    {
        
SendClientMessage(playeridCOLOR_GREY"Your phone is off.");
        return 
1;
    }
    
format(stringsizeof(string), "* %s takes out a cellphone."RPN(playerid));
    
SendNearbyMessage(playerid30.0stringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    if(
phonenumb == 911)
    {
        
SendClientMessage(playeridCOLOR_WHITE"HINT: You now use T to talk on your cellphone, type /hangup to hang up.");
        
SendClientMessage(playeridCOLOR_ALLDEPT"EMERGENCY: Which service do you require, police or paramedic?");
        
Mobile[playerid] = 911;
        if(
PlayerInfo[playerid][pDead] == 1)
        {
            
ApplyAnimation(playerid"KNIFE""KILL_Knife_Ped_Die"4.0011101);
        }
        else
        {
            
SetPlayerSpecialAction(playeridSPECIAL_ACTION_USECELLPHONE);
            
SetPlayerAttachedObject(playerid93306);
        }
        return 
1;
    }
    if(
phonenumb == 745)
    {
        
SendClientMessage(playeridCOLOR_GREY"Thank you for calling a Taxi, we will send your request to way. They hang up..");
        new 
Float:PosXFloat:PosYFloat:PosZ;
        
GetPlayerPos(playeridPosXPosYPosZ);
        foreach(
Playeri)
        {
            if(
IsATaxidriver(i))
            {
                
SetPlayerCheckpoint(iPosXPosYPosZ5.0);
            }
        }
        return 
1;
    }
    if(
phonenumb == PlayerInfo[playerid][pNumber])
    {
        
SendClientMessage(playeridCOLOR_WHITE"  You just get a busy tone...");
        return 
1;
    }
    if(
Mobile[playerid] != INVALID_PLAYER_ID)
    {
        
SendClientMessage(playeridCOLOR_WHITE"You're already in a call...");
        return 
1;
    }
    foreach(
Playeri)
    {
        if(
PlayerInfo[i][pNumber] == phonenumb && phonenumb != 0)
        {
            new 
giveplayerid i;
            
Mobile[playerid] = giveplayerid//caller connecting
            
if(IsPlayerConnected(giveplayerid))
            {
                if(
giveplayerid != INVALID_PLAYER_ID)
                {
                    if(
PhoneOnline[giveplayerid] > 0)
                    {
                        
SendClientMessage(playeridCOLOR_GREY"That player's phone is switched off.");
                        
Mobile[playerid] = INVALID_PLAYER_ID;
                        return 
1;
                    }
                    if(
Mobile[giveplayerid] != INVALID_PLAYER_ID)
                    {
                        
SendClientMessage(playeridCOLOR_WHITE"You just get a busy tone...");
                        
Mobile[playerid] = INVALID_PLAYER_ID;
                        return 
1;
                    }
                    if(
Spec[giveplayerid]!=0)
                    {
                        
SendClientMessage(playeridCOLOR_WHITE"You just get a busy tone...");
                        
Mobile[playerid] = INVALID_PLAYER_ID;
                        return 
1;
                    }
                    if(
Mobile[giveplayerid] == INVALID_PLAYER_ID)
                    {
                        
format(stringsizeof(string), "Your mobile is ringing - type /pickup to answer it. [Caller ID: %s]"RPN(playerid));
                        
SendClientMessage(giveplayeridCOLOR_YELLOWstring);
                        
format(stringsizeof(string), "* %s's phone begins to ring."RPN(i));
                        
SendClientMessage(playeridCOLOR_WHITE"HINT: You now use T to talk on your cellphone, type /hangup to hang up.");
                        
SendNearbyMessage(playerid30.0stringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                        
CellTime[playerid] = 1;
                        
SetPlayerSpecialAction(playeridSPECIAL_ACTION_USECELLPHONE);
                        
SetPlayerAttachedObject(playerid93306);
                        return 
1;
                    }
                }
            }
        }
    }
    
//SendClientMessage(playerid, COLOR_WHITE, "Your call can't be completed as dialed, please check the number and try again.");
    
return 1;

PHP код:
CMD:pickup(playeridparams[])
{
    if(
Mobile[playerid] != INVALID_PLAYER_ID)
    {
        
SendClientMessage(playeridCOLOR_WHITE"  you're already on a call...");
        return 
1;
    }
    foreach(
Playeri)
    {
        if(
Mobile[i] == playerid)
        {
            
Mobile[playerid] = i//caller connecting
            
SendClientMessage(i,  COLOR_WHITE"   They picked up the call.");
            
SetPlayerSpecialAction(playeridSPECIAL_ACTION_USECELLPHONE);
            
SetPlayerAttachedObject(playerid93306);
        }
    }
    return 
1;

Reply
#2

https://sampwiki.blast.hk/wiki/PlayerPlaySound

Edit: 3600 - Calling tone

I think this is what you need
Reply
#3

Just a tip to optimize your codes

PHP код:
if(Mobile[playerid] != INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_WHITE"  you're already on a call..."); 
Instead of:

PHP код:
if(Mobile[playerid] != INVALID_PLAYER_ID
    { 
        
SendClientMessage(playeridCOLOR_WHITE"  you're already on a call..."); 
        return 
1
    } 
Reply
#4

Quote:
Originally Posted by ilijap
Посмотреть сообщение
https://sampwiki.blast.hk/wiki/PlayerPlaySound

Edit: 3600 - Calling tone

I think this is what you need
Thank you.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)