13.06.2012, 21:18
I honestly have no idea how I didn't see it before.
You are getting the name of playerid, not giveplayerid, and your setting playerid's faction to the factionid. I just changed it to giveplayerid so it would set the actual players faction.
pawn Код:
dcmd_setfaction(playerid, params[])
{
new giveplayerid, amount;
if(sscanf(params, "ud", giveplayerid, amount)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /setfaction [playerid] [factionid]");
else if(giveplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
else
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(giveplayerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!dini_Exists(file))
{
SendClientMessage(playerid, 0xFF0000AA, "Player is not registred");
}
if(fexist(file))
{
PlayerInfo[giveplayerid][pFaction] = amount;
dini_IntSet(SERVER_USER_FILE, "Faction",amount);
}
}
return 1;
}