Cellphone Help zGaming
#1

When a player types /hangup and tries to chat, they are still talking into the cellphone. So basically the phone never hangs up.

PHP код:
CMD:hangup(playeridparams[])
{
    new 
string[128];
       if(!
IsPlayerLoggedIn(playerid)) return SendClientMessage(playeridCOLOR_GREY"You need to login first before using any command.");
    if(!
PlayerInfo[playerid][pHasCellphone]) return SendClientMessage(playeridCOLOR_GREY"You don't own a cellphone.");
    if(!
BeingCalled[playerid] && !Calling[playerid]) return SendClientMessage(playeridCOLOR_GREY"You are not on a call nor is anybody calling you.");
    
format(stringsizeof(string), "* %s puts their cellphone away."RPN(playerid));
    
SendNearbyMessage(playerid15stringCOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLE);
    
SendClientMessage(playeridCOLOR_ORANGE" You have hungup the line.");
    if(
BeingCalled[playerid]) SendClientMessage(Caller[playerid], COLOR_ORANGE" They hungup the line.");
    else if(
Calling[playerid]) SendClientMessage(Called[playerid], COLOR_ORANGE" They hungup the line.");
    
//
    
SetPlayerSpecialAction(playeridSPECIAL_ACTION_STOPUSECELLPHONE);
    if(
Calling[playerid])
    {
        
SetPlayerSpecialAction(Called[playerid], SPECIAL_ACTION_STOPUSECELLPHONE);
        
format(stringsizeof(string), "[Cellphone] Phonecall lasted for %d seconds, price: $%d"CallTime[playerid], CallTime[playerid]*10/100);
        
SendClientMessage(playeridCOLOR_YELLOWstring);
        
GiveZaiatMoney(playerid, -(CallTime[playerid]*10/100));
        
TaxMoney += (CallTime[playerid]*10/100);
        
Calling[playerid] = 0;
        
BeingCalled[playerid] = -1;
        
Caller[playerid] = 0;
        
CallTime[playerid] = 0;
        
Called[playerid] = -1;
    }
    else if(
Calling[Caller[playerid]])
    {
        
SetPlayerSpecialAction(Called[playerid], SPECIAL_ACTION_STOPUSECELLPHONE);
        
format(stringsizeof(string), "[Cellphone] Phonecall lasted for %d seconds, price: $%d"CallTime[Caller[playerid]], CallTime[Caller[playerid]]*10/100);
        
SendClientMessage(Caller[playerid], COLOR_YELLOWstring);
        
GiveZaiatMoney(Caller[playerid], -(CallTime[Caller[playerid]]*10/100));
        
TaxMoney += (CallTime[Caller[playerid]]*10/100);
        
Calling[Called[playerid]] = 0;
        
BeingCalled[Called[playerid]] = -1;
        
Caller[Called[playerid]] = 0;
        
CallTime[Called[playerid]] = 0;
        
Called[Called[playerid]] = -1;
    }
    return 
1;

PHP код:
if(BeingCalled[playerid] == || Calling[playerid] == || Call911[playerid])
    {
        if(
strlen(PlayerInfo[playerid][pAccent])) format(stringsizeof(string), "[Cellphone] %s: [%s Accent] %s"RPN(playerid), PlayerInfo[playerid][pAccent], text);
        else 
format(stringsizeof(string), "[Cellphone] %s: %s"RPN(playerid), text);
        if(!
Call911[playerid])
        {
            if(
BeingCalled[playerid] == 2SendClientMessage(Caller[playerid], COLOR_YELLOWstring);
            else if(
Calling[playerid] == 2SendClientMessage(Called[playerid], COLOR_YELLOWstring);
        }
    } 
Reply
#2

The way your command has its if and else if statements will not allow both caller's and receiver's variables to be reset, rather only one's variables get reset.

Also, why do you first multiply the call time by 10 and then divide it by 100? Wouldn't it be the same to just divide by 10?
Reply
#3

Do you know how I could fix this then?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)