Question about my commands. -
PaulDinam - 16.02.2013
Is that okay to use PVarInt on it, or should I use global variables?
Код:
CMD:convo(playerid, params[])
{
new pid, str[128];
if(sscanf(params,"d",pid)) return SyntaxMSG(playerid, "/convo [playerid]");
if(GetIntVar(playerid, "InConvo") == 1) return ConvoMSG(playerid, "You are talking already, '/endconvo' first.");
if(!PlayerIsOn(pid)) return NotConnectedMSG(playerid);
SetIntVar(playerid, "InConvo", 1);
SetIntVar(playerid, "ConvoWith", pid);
format(str, sizeof(str), "[ID:%d]%s has started a conversation with you, you may convo with him by /convo. (NOTE: This is an OOC'ly chat)", playerid, GetName(playerid));
ConvoMSG(pid, str);
ConvoMSG(playerid, "You may start talking with the person, by typing normally. (NOTE: This is an OOC'ly chat)");
return 1;
}
CMD:endconvo(playerid, params[])
{
new str[128];
if(GetIntVar(playerid, "InConvo") == 0) return ConvoMSG(playerid, "You are not talking in a convo.");
format(str, sizeof(str), "[ID:%d]%s has ended the conversation with you.", playerid, GetName(playerid));
ConvoMSG(GetIntVar(playerid, "ConvoWith"), str);
format(str, sizeof(str), "You have stopped the conversation with [ID:%d]%s", GetIntVar(playerid, "ConvoWith"), GetName(GetIntVar(playerid, "ConvoWith")));
ConvoMSG(playerid, str);
RemoveVar(playerid, "InConvo");
RemoveVar(playerid, "ConvoWith");
return 1;
}
Re : Question about my commands. -
DaRk_RaiN - 16.02.2013
PVar's are the best choice in this case.
Re: Question about my commands. -
PaulDinam - 16.02.2013
Okay one more question:
OnPlayerDisconnected, I made a check if the player is in a convo:
Код:
foreach(Player, i)
{
if(GetIntVar(i, "InConvo") == 1 && GetIntVar(i, "ConvoWith") == playerid)
{
format(string, sizeof(string), "[ID:%d]%s has been disconnected from the server, the convo has ended.", playerid, GetName(playerid));
ConvoMSG(i, string);
RemoveVar(i, "InConvo");
RemoveVar(i, "ConvoWith");
}
}
My question is if this code is fine.
Re : Question about my commands. -
DaRk_RaiN - 16.02.2013
Code fixed bellow
Re: Question about my commands. -
PaulDinam - 16.02.2013
But I send the message for the convo maker lol... that's why I need loop to check if some player is in convo with him.
Re : Question about my commands. -
DaRk_RaiN - 16.02.2013
Oh ok then
pawn Код:
foreach(Player, i)
{
if(GetIntVar(i, "InConvo") == 1 && i != playerid)
{
format(string, sizeof(string), "[ID:%d]%s has been disconnected from the server, the convo has ended.", playerid, GetName(playerid));
ConvoMSG(i, string);
RemoveVar(i, "InConvo");
RemoveVar(i, "ConvoWith");
}
}