Posts: 791
Threads: 65
Joined: Oct 2009
Reputation:
0
so whats the best way to create the command /r reply to your last received pm .. exactly like in Cb's cnr...
so if im ID 1 and i pm ID 2, ID 2 can use the command /r to reply back to ID 1
same goes for id 1 after 2 has replied him back, hope u understand. plz help=s
Posts: 6,129
Threads: 36
Joined: Jan 2009
Create a PVar, or normal variable, storing the ID of the person who last PMed the player in the variable, then use /r to check that ID and send the reply to that ID.
In your PM command:
pawn Код:
/* for this explanation, iTarget is the player who is receiving the PM and playerid is the one sending it */
SetPVarInt(iTarget, "LastPMFrom", playerid);
In your reply command:
pawn Код:
new iTarget = GetPVarInt(playerid, "LastPMFrom");
/* iTarget being the target of the reply */
Posts: 791
Threads: 65
Joined: Oct 2009
Reputation:
0
thanks man and this wont mess up when more then 2 players pm each other?
also how can i check if PvarInt isset ?
Posts: 6,129
Threads: 36
Joined: Jan 2009
If 2 people PM the person, the person will be able to reply to the last incoming PM.
If that's not what you want, could you be a bit more specific?
Also, you can use GetPVarType() and if it's 0, it's not a created PVar.
Posts: 6,129
Threads: 36
Joined: Jan 2009
Quote:
Originally Posted by Lorenc_
pawn Код:
if(GetPVarInt(playerid, "RespondingID")) //if it's set { } else //else if it isn't { }
EDIT: sorry was afk and waiting for the posting time to decrease.
|
That will trigger an error if the value is 0, if a PVar doesn't exist, it'll automatically return 0. Using GetPVarType will accurately determine whether the PVar currently exists or not.
Lorenc_'s code will not work for player ID 0.