How to create /invite and /accept - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to create /invite and /accept (
/showthread.php?tid=467475)
How to create /invite and /accept -
Ahmed10020 - 03.10.2013
Hi i was wounder to know how to make /invite and sendclientmessage to the target player id for example
pawn Код:
format(string,sizeof(string),"%s has invite you to ... %s"
Using
Код:
Zcmd Y_ini (if it needed) and sscanf
Re: How to create /invite and /accept -
MAFIAWARS - 03.10.2013
pawn Код:
CMD:invite(playerid, params[])
{
new id, PlayerName[24];
if(sscanf(params,"u",playerid)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /invite <playerid>
SendClientMessage(id, COLOR_RED, "%s has invited you to... !", PlayerName);
return 1;
}
I hope this will help you.
Re: How to create /invite and /accept -
Ahmed10020 - 03.10.2013
Thanks for reply , but i already know this
I want /accept script not invite but thanks anyway
Re: How to create /invite and /accept -
Fez - 03.10.2013
Try this.
Код:
command(hire, playerid, params[])
{
if(Player[playerid][Faction] >= 1)
{
if(Player[playerid][FactionRank] >= 6)
{
new id, string[512], string1[128];
if(sscanf(params, "u", id)) return SendClientMessage(playerid, WHITE, "Server: /hire [playerid/name]");
{
if(Player[id][Faction] == 0)
{
if(Player[playerid][FactionRank] == 6)format(string1, sizeof(string1), "%s", Factions[Player[playerid][Faction]][RankSix]);
else if(Player[playerid][FactionRank] == 7)format(string1, sizeof(string1), "%s", Factions[Player[playerid][Faction]][RankSeven]);
format(string, sizeof(string), "%s %s wants you to join thier Faction. (%s) Use '/accept faction' to join.", string1, RemoveUnderScore(playerid), Factions[Player[playerid][Faction]][FactionName]);
SendClientMessage(id, WHITE, string);
format(string, sizeof(string), "You have invited %s to join %s.", RemoveUnderScore(id), Factions[Player[playerid][Faction]][FactionName]);
SendClientMessage(playerid, WHITE, string);
InvitedTo[id] = Player[playerid][Faction];
}
else return SendClientMessage(playerid, WHITE, "That player is already in a Faction.");
}
}
else return SendClientMessage(playerid, WHITE, "You aren't a high enough rank to use this command.");
}
else return SendClientMessage(playerid, WHITE, "You must be in a Faction to use this command.");
return 1;
}
Re: How to create /invite and /accept -
DanishHaq - 03.10.2013
pawn Код:
new invitedfrom[MAX_PLAYERS];
CMD:invite(playerid, params[], help)
{
new giveplayerid;
if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "/invite [playerid/name]");
if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFFFFFFFF, "Error: Player not connected.");
new string[100], sender[MAX_PLAYER_NAME], receiver[MAX_PLAYER_NAME];
GetPlayerName(playerid, sender, sizeof(sender));
GetPlayerName(giveplayerid, receiver, sizeof(receiver));
format(string, sizeof(string), "%s is inviting you to join their faction, type /acceptinvite to join the faction.", sender);
SendClientMessage(giveplayerid, 0xFFFFFFFF, string);
format(string, sizeof(string), "You have invited %s to join your faction, please wait while he accepts your invite request");
SendClientMessage(playerid, 0xFFFFFFFF, string);
invitedfrom[giveplayerid] = playerid; // stores the player id to the invited from
return 1;
}
CMD:acceptinvite(playerid, params[], help)
{
if(invitedfrom[playerid] == -1) return SendClientMessage(playerid, 0xFFFFFFFF, "You haven't been invited anywhere.");
// use the invitedfrom variable to get the other player's faction ID, i.e. something like this:
new other = invitedfrom[playerid];
PlayerInfo[playerid][pMember] = PlayerInfo[other][pLeader];
PlayerInfo[playerid][pRank] = 1;
// do the rest of your code here
return 1;
}
public OnPlayerConnect(playerid) // make sure you have this
{
invitedfrom[playerid] = -1;
return 1;
}
I'd recommend you set a timer that will cancel it after like 2 minutes, just to not cause any type of errors.