How can i add phone in my hand when i use /call
#1

Hello i have a /call script but i doesnt have a phone in my hand.How can i add phone when i use /call ?

pawn Код:
new cmd[256],idx;
    cmd=strtok(cmdtext,idx);
    //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  // |
    if(!strcmp(cmd,"/call",true))
    {
        tmp=strtok(cmdtext,idx);
        docommand=playerid;
        id=strval(tmp);
        if(GetPlayerState(docommand) == PLAYER_STATE_DRIVER )return SendClientMessage(docommand,RED,"#Error: Dont drive and talk in Phone!!");
        if(!strlen(tmp)) return SendClientMessage(docommand,RED,"#Error: /Call [ID]");
        if(!IsPlayerConnected(id)) return SendClientMessage(docommand,RED,"#Error: Incorrect ID");
        if(IsPlayerNPC(id))return SendClientMessage(docommand,RED,"#Error: This Player is a NPC !");
        if(id==playerid)return SendClientMessage(docommand,RED,"#Error: You cannot call to your self!");
        format(str,128,"Make a call to '%s', Please wait ... ",GetName(id));
        SendClientMessage(docommand,WHITE,str);
        format(str,128,"The player %s in now calling to you.",GetName(docommand));
        SendClientMessage(id,WHITE,str);
        SendClientMessage(id,BLUEWHITE,"To answer the call type /Answer ••• To ignore the call type /Ignore.");
        InCall[docommand]=0,InCall[id]=0;
        GetCall[docommand]=0,GetCall[id]=1;
        return 1;
    }
    gc=id; sender=docommand;
    //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  // |
    if(!strcmp(cmd,"/ignore",true))
    {
        if(GetCall[playerid]==0)return SendClientMessage(playerid,RED,"#Error: Your not get a call.");
        format(str,128,"Your ignore the call from %s.",GetName(sender));
        SendClientMessage(gc,GREEN,str);
        format(str,128,"The player %s in ignore the call.",GetName(gc));
        SendClientMessage(sender,GRAY,str);
        InCall[sender]=0,InCall[gc]=0;
        GetCall[sender]=0,GetCall[gc]=0;
        return 1;
    }
    //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  // |
    if(!strcmp(cmd,"/answer",true))
    {
        if(GetCall[playerid]==0)return SendClientMessage(playerid,RED,"#Error: Your not get a call.");
        if(InCall[playerid]==1)return SendClientMessage(playerid,RED,"#Error: Your in call now.");
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)return SendClientMessage(playerid,RED,"#Error: Dont drive and talk in Phone!!");
        format(str,128,"Your answer the call from %s.",GetName(sender));
        SendClientMessage(gc,GREEN,str);
        format(str,128,"The player %s in anwer the call.",GetName(gc));
        SendClientMessage(sender,GREEN,str);
        InCall[sender]=1,InCall[gc]=1; GetCall[sender]=0,GetCall[gc]=0;
        SetPlayerSpecialAction(sender,SPECIAL_ACTION_USECELLPHONE);
        SetPlayerSpecialAction(gc,SPECIAL_ACTION_USECELLPHONE);
        return 1;
    }
    //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  // |
    if(!strcmp(cmd,"/hangup",true))
    {
        if(InCall[gc]==0)return SendClientMessage(gc,RED,"#Error: Your not in call now.");
        if(gc==playerid)
        {
            format(str,128,"You hangup the call from %s.",GetName(sender));
            SendClientMessage(gc,GREEN,str);
            format(str,128,"The player %s in hangup the call.",GetName(gc));
            SendClientMessage(sender,GRAY,str);
            SetPlayerSpecialAction(gc,SPECIAL_ACTION_STOPUSECELLPHONE);
            SetPlayerSpecialAction(sender,SPECIAL_ACTION_STOPUSECELLPHONE);
            InCall[gc]=0,GetCall[gc]=0; InCall[sender]=0,GetCall[sender]=0;
        }
        if(sender==playerid)
        {
            format(str,128,"You hangup the call from %s.",GetName(gc));
            SendClientMessage(sender,GREEN,str);
            format(str,128,"The player %s in hangup the call.",GetName(sender));
            SendClientMessage(gc,GRAY,str);
            SetPlayerSpecialAction(gc,SPECIAL_ACTION_STOPUSECELLPHONE);
            SetPlayerSpecialAction(sender,SPECIAL_ACTION_STOPUSECELLPHONE);
            InCall[gc]=0,GetCall[gc]=0; InCall[sender]=0,GetCall[sender]=0;
        }
        return 1;
    }
    //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  // |
    if(!strcmp(cmdtext,"/phone credit",true))return SendClientMessage(playerid,BLUEWHITE,"Phone System Created By: _Tw1xEr_ [Maor]");
    return 0;
}

public OnPlayerConnect(playerid)return InCall[playerid]=0,GetCall[playerid]=0;

public OnPlayerDisconnect(playerid, reason)
{
    if(InCall[playerid]==1)
    {
        if(playerid==sender)
        {
            InCall[gc]=0,GetCall[gc]=0; InCall[sender]=0,GetCall[sender]=0;
            SetPlayerSpecialAction(gc,SPECIAL_ACTION_STOPUSECELLPHONE);
            format(str,128,"%s hes disconnect from the server. The call is shut down.",GetName(sender));
            SendClientMessage(gc,GRAY,str);
        } else if(playerid == gc)
        {
            InCall[gc]=0,GetCall[gc]=0; InCall[sender]=0,GetCall[sender]=0;
            SetPlayerSpecialAction(sender,SPECIAL_ACTION_STOPUSECELLPHONE);
            format(str,128,"%s hes disconnect from the server. The call is shut down.",GetName(gc));
            SendClientMessage(sender,GRAY,str);
        }
    }
    return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(InCall[playerid]==1)return SendClientMessage(playerid,RED,"#Error: Dont drive and talk in Phone!!");
    return 1;
}

public OnPlayerText(playerid, text[])
{
    if(InCall[playerid]==1)
    {
        format(str,128,"[Phone] %s [# %d]: %s",GetName(playerid),playerid,text);
        SendClientMessage(gc,BLUEWHITE,str);
        format(str,128,"[Phone] %s [# %d]: %s",GetName(playerid),playerid,text);
        SendClientMessage(sender,BLUEWHITE,str);
        return 0;
    }
    return 1;
}

//Stocks:
stock GetName(playerid)
{
    new Name[24];
    GetPlayerName(playerid,Name,24);
    return Name;
}

strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Reply
#2

In answer or call
pawn Код:
SetPlayerAttachedObject(playerid, 4, 330, 6); // 4 = attachment slot, 330 = cellphone model, 6 = right hand

and on hangup
pawn Код:
RemovePlayerAttachedObject(playerid, 4);
Reply
#3

pawn Код:
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
^^ That's what you need.

EDIT:Ice was faster...
Reply
#4

PHP код:
SetPlayerSpecialAction(playeridSPECIAL_ACTION_USECELLPHONE); 
Reply
#5

But where to add that
Reply
#6

Before the first "return 1;"
Reply
#7

In my script i have SetPlayerSpecialAction(sender,SPECIAL_ACTION_USECE LLPHONE);
SetPlayerSpecialAction(gc,SPECIAL_ACTION_USECELLPH ONE);
Reply
#8

No guys he wants the object cellphone when you're on a call.
Ok so use this:
pawn Код:
new cmd[256],idx;
    cmd=strtok(cmdtext,idx);
    //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  // |
    if(!strcmp(cmd,"/call",true))
    {
        tmp=strtok(cmdtext,idx);
        docommand=playerid;
        id=strval(tmp);
        if(GetPlayerState(docommand) == PLAYER_STATE_DRIVER )return SendClientMessage(docommand,RED,"#Error: Dont drive and talk in Phone!!");
        if(!strlen(tmp)) return SendClientMessage(docommand,RED,"#Error: /Call [ID]");
        if(!IsPlayerConnected(id)) return SendClientMessage(docommand,RED,"#Error: Incorrect ID");
        if(IsPlayerNPC(id))return SendClientMessage(docommand,RED,"#Error: This Player is a NPC !");
        if(id==playerid)return SendClientMessage(docommand,RED,"#Error: You cannot call to your self!");
        format(str,128,"Make a call to '%s', Please wait ... ",GetName(id));
        SendClientMessage(docommand,WHITE,str);
        format(str,128,"The player %s in now calling to you.",GetName(docommand));
        SendClientMessage(id,WHITE,str);
        SendClientMessage(id,BLUEWHITE,"To answer the call type /Answer ••• To ignore the call type /Ignore.");
        InCall[docommand]=0,InCall[id]=0;
        GetCall[docommand]=0,GetCall[id]=1;
        return 1;
    }
    gc=id; sender=docommand;
    //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  // |
    if(!strcmp(cmd,"/ignore",true))
    {
        if(GetCall[playerid]==0)return SendClientMessage(playerid,RED,"#Error: Your not get a call.");
        format(str,128,"Your ignore the call from %s.",GetName(sender));
        SendClientMessage(gc,GREEN,str);
        format(str,128,"The player %s in ignore the call.",GetName(gc));
        SendClientMessage(sender,GRAY,str);
        InCall[sender]=0,InCall[gc]=0;
        GetCall[sender]=0,GetCall[gc]=0;
        return 1;
    }
    //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  // |
    if(!strcmp(cmd,"/answer",true))
    {
        if(GetCall[playerid]==0)return SendClientMessage(playerid,RED,"#Error: Your not get a call.");
        if(InCall[playerid]==1)return SendClientMessage(playerid,RED,"#Error: Your in call now.");
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)return SendClientMessage(playerid,RED,"#Error: Dont drive and talk in Phone!!");
        format(str,128,"Your answer the call from %s.",GetName(sender));
        SendClientMessage(gc,GREEN,str);
        format(str,128,"The player %s in anwer the call.",GetName(gc));
        SendClientMessage(sender,GREEN,str);
        InCall[sender]=1,InCall[gc]=1; GetCall[sender]=0,GetCall[gc]=0;
        SetPlayerAttachedObject(sender, 4, 330, 6);
        SetPlayerAttachedObject(gc, 4, 330, 6);
        SetPlayerSpecialAction(sender,SPECIAL_ACTION_USECELLPHONE);
        SetPlayerSpecialAction(gc,SPECIAL_ACTION_USECELLPHONE);
        return 1;
    }
    //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  // |
    if(!strcmp(cmd,"/hangup",true))
    {
        if(InCall[gc]==0)return SendClientMessage(gc,RED,"#Error: Your not in call now.");
        if(gc==playerid)
        {
            format(str,128,"You hangup the call from %s.",GetName(sender));
            SendClientMessage(gc,GREEN,str);
            format(str,128,"The player %s in hangup the call.",GetName(gc));
            SendClientMessage(sender,GRAY,str);
            SetPlayerSpecialAction(gc,SPECIAL_ACTION_STOPUSECELLPHONE);
            RemovePlayerAttachedObject(gc, 4);
            RemovePlayerAttachedObject(sender, 4);
            SetPlayerSpecialAction(sender,SPECIAL_ACTION_STOPUSECELLPHONE);
            InCall[gc]=0,GetCall[gc]=0; InCall[sender]=0,GetCall[sender]=0;
        }
        if(sender==playerid)
        {
            format(str,128,"You hangup the call from %s.",GetName(gc));
            SendClientMessage(sender,GREEN,str);
            format(str,128,"The player %s in hangup the call.",GetName(sender));
            SendClientMessage(gc,GRAY,str);
            SetPlayerSpecialAction(gc,SPECIAL_ACTION_STOPUSECELLPHONE);
            RemovePlayerAttachedObject(gc, 4);
            RemovePlayerAttachedObject(sender, 4);
            SetPlayerSpecialAction(sender,SPECIAL_ACTION_STOPUSECELLPHONE);
            InCall[gc]=0,GetCall[gc]=0; InCall[sender]=0,GetCall[sender]=0;
        }
        return 1;
    }
    //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  // |
    if(!strcmp(cmdtext,"/phone credit",true))return SendClientMessage(playerid,BLUEWHITE,"Phone System Created By: _Tw1xEr_ [Maor]");
    return 0;
}

public OnPlayerConnect(playerid)return InCall[playerid]=0,GetCall[playerid]=0;

public OnPlayerDisconnect(playerid, reason)
{
    if(InCall[playerid]==1)
    {
        if(playerid==sender)
        {
            InCall[gc]=0,GetCall[gc]=0; InCall[sender]=0,GetCall[sender]=0;
            SetPlayerSpecialAction(gc,SPECIAL_ACTION_STOPUSECELLPHONE);
            RemovePlayerAttachedObject(gc, 4);
            format(str,128,"%s hes disconnect from the server. The call is shut down.",GetName(sender));
            SendClientMessage(gc,GRAY,str);
        } else if(playerid == gc)
        {
            InCall[gc]=0,GetCall[gc]=0; InCall[sender]=0,GetCall[sender]=0;
            SetPlayerSpecialAction(sender,SPECIAL_ACTION_STOPUSECELLPHONE);
            RemovePlayerAttachedObject(sender, 4);
            format(str,128,"%s hes disconnect from the server. The call is shut down.",GetName(gc));
            SendClientMessage(sender,GRAY,str);
        }
    }
    return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(InCall[playerid]==1)return SendClientMessage(playerid,RED,"#Error: Dont drive and talk in Phone!!");
    return 1;
}

public OnPlayerText(playerid, text[])
{
    if(InCall[playerid]==1)
    {
        format(str,128,"[Phone] %s [# %d]: %s",GetName(playerid),playerid,text);
        SendClientMessage(gc,BLUEWHITE,str);
        format(str,128,"[Phone] %s [# %d]: %s",GetName(playerid),playerid,text);
        SendClientMessage(sender,BLUEWHITE,str);
        return 0;
    }
    return 1;
}

//Stocks:
stock GetName(playerid)
{
    new Name[24];
    GetPlayerName(playerid,Name,24);
    return Name;
}

strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Reply
#9

No problem, these don't make any errors if you have more than 1.
Edit: oops too late.
Reply
#10

Okay bro thanks so much
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)