Problem
#1

I made a faction invite command:

pawn Код:
CMD:finvita(playerid, params[])
{
    if(!Player[playerid][FactionLeader]) return SCM(playerid, COLOR_LIGHTRED, "Solamente un CF puт utilizzare questo comando!");
   
    new id;

    if(sscanf(params, "r", id))return SCM(playerid, COLOR_GREY, "/finvita <playerid/nome>");

    if(!IsPlayerConnected(id) || id == playerid) return SCM(playerid, COLOR_GREY, "Playerid/nome non valido.");

    if(Player[id][IsInFaction]) return SCM(playerid, COLOR_GREY, "Questo giocatore appartiene giа ad un'altra fazione.");

    Player[id][pRequesterFaction] = playerid;

    SendClientMessageEx(id, COLOR_YELLOW, "%s vuole fazionarti nella fazione %s. Digita /accetta fazione per confermare.", ReturnName(playerid, 0), Player[playerid][FactionName]);
    SendClientMessageEx(playerid, COLOR_YELLOW, "Richiesta di fazionamento inviata a %s.", ReturnName(id, 0));

   
    return 1;
}
And the /accept faction:

pawn Код:
CMD:accetta(playerid, params[])
{
    new senderid;
   
    if(isnull(params) || strlen(params) > 80) return SCM(playerid, COLOR_GREY, "/accetta <fazione>");
   
    if(!strcmp(params, "fazione", true))
    {
        if(Player[playerid][pRequesterFaction] == 0) return SCM(playerid, COLOR_GREY, "Nessuno ti ha invitato ad entrare in una fazione!");
       
        if(Player[playerid][IsInFaction] == 1) return SCM(playerid, COLOR_GREY, "Sei gia' in una fazione");
       
        senderid = Player[playerid][pRequesterFaction];

        SendClientMessageEx(senderid, COLOR_YELLOW, "%s ha accettato la tua richiesta di fazionamento.", ReturnName(playerid, 0));
        SendClientMessageEx(playerid, COLOR_YELLOW, "Richiesta di fazionamento da parte di %s accettata.", ReturnName(senderid, 0));
       
        new fname = Player[senderid][FactionName];

        Player[playerid][PlayerFactionID] = Player[senderid][PlayerFactionID];
       
        Player[playerid][FactionName] = fname;

        Player[playerid][pRequesterFaction] = -1;
       
        Player[playerid][IsInFaction] = 1;
    }
    return 1;
}
It works. It sets correct faction id but for FactionName i have a problem.

It should take the faction name of who sent the invite and assign it at the invited player as PlayerFactionID, but it shows just the first letter of faction. Ex: LSPD, it shows just "L" in db and with a command i have.

I saved it as varchar 32 in database, same with loading/saving. I have another command which creates the faction and name is assigned correctly.

What's wrong?
Reply
#2

When it shows "You have been invited to faction %s" place it as

PHP код:
    format(stringsizeof(string), "You've invited %s to join to the faction %s!"targetnameGetFactionName(playerid));
    
SendClientMessage(playerid, -1string);
    
format(string2sizeof(string), "You've been invited to join %s by %s!"GetFactionName(playerid), ReturnName);
    
SendClientMessage(targetid, -1string2); 

Definy GetFactionName as
PHP код:
stock GetFactionName(playerid)
{
    new 
factionname[64];
    switch(
Player[playerid][PlayerFactionID])
    {
        case 
0factionname "Civilian";
        case 
1factionname "Faction1";
        case 
2factionname "Faction";
    }
    return 
factionname;

Reply
#3

Ok and what about FactionName i should set in player enum?
Reply
#4

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
Ok and what about FactionName i should set in player enum?
No. You don't have to enum that in playerenum.

in enum you have "PlayerFactionID"


if playerfactionid is 1, it will show "Faction1"

(because of case. every case number is factionid.)

PHP код:
stock GetFactionName(playerid)
{
    new 
factionname[64];
    switch(
Player[playerid][PlayerFactionID]) // This detects value of PlayerFactionID what you have in playerenum
    
{
        case 
0factionname "Civilian"// This detects playerfactionid as value 0
        
case 1factionname "Faction1"// This detects playerfactionid as value 1
        
case 2factionname "Faction"// This detects playerfactionid as value 2
    
}
    return 
factionname;

Instead of
PHP код:
Player[playerid][FactionName
You will type
PHP код:
GetFactionName(playerid
Reply
#5

Advice

PHP код:
 //It must be less than "0" or another value unreachable by the identifications of the players. Since if the player with the ID "0" assigned sends an invitation to another player, the guest when executing the command will give an error.
if(Player[playerid][pRequesterFaction] == 0) return SCM(playeridCOLOR_GREY"Nessuno ti ha invitato ad entrare in una fazione!");
 
//use this
if(Player[playerid][pRequesterFaction] == -1) return SCM(playeridCOLOR_GREY"Nessuno ti ha invitato ad entrare in una fazione!"); 
To assign the name of the faction to the guest player, use this:

PHP код:
format(Player[playerid][FactionName], 30"%s"fname); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)