String doesnt show up in ClientMessage.
#1

Hello Everyone,

I was creating a faction system for myself. Everything stores fine and loads perfectly. I was creating a command to set someone the leader of a faction. So i made the code below. It works fine InGame , but the only problem is 'I want it to display the name of the faction too but it skips the faction name part. It is null. Nothing shows up in ClientMessage'.

The command just works fine only problem is the name of the faction does not show up.

pawn Код:
COMMAND:afaction(playerid, params[])
{
    new cmd[58];
    if (sscanf(params, "s ", cmd) != 0)
    {
        return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /afaction setleader");
    }
    if (strcmp("setleader", cmd, true, 10) == 0)
    {
        new factionid,player,string[95];
        if (!sscanf(params, "sud", cmd, player,factionid))
        {
           if(player == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE, "ERROR: That player is not connected.");
           if(FactionExists(factionid))
           {
                Character[player][cFactionID] = factionid;
                Character[player][cFactionRank] = 5;
                format(string,sizeof(string),"You have been made the leader of the Faction: %s by an Admin.",Factions[factionid][fName]);
                SendClientMessage(player,COLOR_GREEN,string);
            }
            else return SendClientMessage(playerid, COLOR_WHITE, "ERROR: That faction does not exist. Please check again");
        }
        else return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /afaction setleader <playerid)> <factionid>");

    }
    return 1;
}

Why exactly i dont see the name of the faction? The ID is fine and everything else. I save and load things using SQLite. Help will be appreciated a lot.


Thanks
Reply
#2

I'm not trying to sound mean, since I know you're good I will point you to this direction.


Your error remains between these two lines.
Код:
new factionid,player,string[95];
if (!sscanf(params, "sud", cmd, player,factionid))
Reply
#3

Quote:
Originally Posted by Akira297
Посмотреть сообщение
I'm not trying to sound mean, since I know you're good I will point you to this direction.


Your error remains between these two lines.
Код:
new factionid,player,string[95];
if (!sscanf(params, "sud", cmd, player,factionid))
But Kira it works fine. The parameters works fine too. It set's the correct playerid the leader of faction id provided.

If Faction ID is not valid then returns the error also. Faction ID and Rank saves fine too. But Client Message doesnt show the name of the faction? Damn thats weird.
Reply
#4

Код:
format(string,sizeof(string),"You have been made the leader of the Faction: %s by an Admin.",Factions[factionid][fName]);
-.-
Reply
#5

Quote:
Originally Posted by Akira297
Посмотреть сообщение
Код:
format(string,sizeof(string),"You have been made the leader of the Faction: %s by an Admin.",Factions[factionid][fName]);
-.-
EDIT: Got the problem in the end. The SQLID of the faction is 1 but the InGame Vaue of the Array is 0.

The there are two ID's of every faction which are SQLID: 1 and IG-ID: 0.

It works fine when i use FactionExistsEx function and use 0 as the faction ID. Shows me the name of the faction
Reply
#6

Look at the ending variables.
Reply
#7

Quote:
Originally Posted by Akira297
Посмотреть сообщение
Look at the ending variables.
Solved Thanks to Kira mah babe for her replies. Rep+6 Added
Reply
#8

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
Solved Thanks to Kira mah babe for her replies. Rep+6 Added
Told you, didn't need any help and you were good
Reply
#9

Try factionid - 1.

EDIT: Too late.
Reply
#10

i just saw this now, it seems solved, but i see no point at using sscanf twice.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)