/setvip command help
#1

I want to make a command that set player vip that I have done but I want to make log file for this command and I want to make "PROMOTED!" & "DEMOTED!" text to player who is promoted/demoted with message "Administrator %s has set you to VIP Status [Level:%d]" (DONE) but I want this too "Administrator %s has set you to Player Status [Level: %d]" I can't make this please help me. Here is the code:
pawn Код:
CMD:setvip(playerid, params[])
{
    if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, RCONERROR);
    {
        if(PlayerInfo[playerid][pVipLevel] == 1) { vrank = "Bronze V.I.P"; }
        else if(PlayerInfo[playerid][pVipLevel] == 2) { vrank = "Silver V.I.P"; }
        else if(PlayerInfo[playerid][pVipLevel] == 3) { vrank = "Gold V.I.P"; }
        {
            new victimname[MAX_PLAYER_NAME], vipname[MAX_PLAYER_NAME], viplevel, giveplayerid, string[128];
            if(sscanf(params, "ui", giveplayerid, viplevel)) return SendClientMessage(playerid, COLOR_DGRAY, "Syntax: /setvip [playerid] [level]");
            if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected");
            if(viplevel > 3 || viplevel < 0) return SendClientMessage(playerid, COLOR_RED, "ERROR: Valid levels: 1-3");
            PlayerInfo[giveplayerid][pVipLevel] = viplevel;
            GetPlayerName(giveplayerid, victimname, sizeof(victimname));
            GetPlayerName(playerid, vipname, sizeof(vipname));
            PlayerInfo[giveplayerid][pVipLevel] = viplevel;
            GetPlayerName(giveplayerid, victimname, sizeof(victimname));
            GetPlayerName(playerid, vipname, sizeof(vipname));
           
            format(string,sizeof(string),"Administrator %s(%d) has set you to VIP Status! [Level: %i]", vipname, playerid, viplevel, giveplayerid);
            SendClientMessage(playerid, COLOR_AQUA, string);
            format(string, sizeof(string), ">> You set %s(%d) VIP level to '%i'", victimname, playerid, viplevel, giveplayerid);
            SendClientMessage(playerid, COLOR_DGRAY, string);
        }
    }
    return 1;
}
Reply
#2

Try this.

pawn Код:
CMD:setvip(playerid, params[])
{
    if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, RCONERROR);
    {
        if(PlayerInfo[playerid][pVipLevel] == 1) { vrank = "Bronze V.I.P"; }
        else if(PlayerInfo[playerid][pVipLevel] == 2) { vrank = "Silver V.I.P"; }
        else if(PlayerInfo[playerid][pVipLevel] == 3) { vrank = "Gold V.I.P"; }
        {
            new victimname[MAX_PLAYER_NAME], vipname[MAX_PLAYER_NAME], notice[20],viplevel, giveplayerid, string[128];
            if(sscanf(params, "ui", giveplayerid, viplevel)) return SendClientMessage(playerid, COLOR_DGRAY, "Syntax: /setvip [playerid] [level]");
            if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected");
            if(viplevel > 3 || viplevel < 0) return SendClientMessage(playerid, COLOR_RED, "ERROR: Valid levels: 1-3");
            PlayerInfo[giveplayerid][pVipLevel] = viplevel;
            if(PlayerInfo[giveplayerid][pVipLevel] > viplevel) { notice="Promoted"; }
            else notice="Demoted"; }
            GetPlayerName(giveplayerid, victimname, sizeof(victimname));
            GetPlayerName(playerid, vipname, sizeof(vipname));
            PlayerInfo[giveplayerid][pVipLevel] = viplevel;
            GetPlayerName(giveplayerid, victimname, sizeof(victimname));
            GetPlayerName(playerid, vipname, sizeof(vipname));
            format(string,sizeof(string),"Administrator %s(%d) has %s you to VIP Status! [Level: %i]", vipname, playerid,notice, viplevel, giveplayerid);
            SendClientMessage(playerid, COLOR_AQUA, string);
            format(string, sizeof(string), ">> You set %s(%d) VIP level to '%i'", victimname, playerid, viplevel, giveplayerid);
            SendClientMessage(playerid, COLOR_DGRAY, string);
        }
    }
    return 1;
}
Reply
#3

I also need a log file to be created and the text will be:
[PROMOTED]: Admin %s has promoted %s to %d level
[DEMOTED]: Admin %s has demoted %s to %d level
Reply
#4

Код:
        new string[128], string1[128], target[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME];
	GetPlayerName(playerid, pName, sizeof(pName));
        GetPlayerName(pID, target, sizeof(target));
        format(string, sizeof(string), "You have set %s Vip level to %i", target, value);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "Your Vip level has been set to %i by %s", value, pName);
        SendClientMessage(pID, -1, string1);
        PlayerInfo[pID][pVip] = value;
If you need more Infomation post your Vip codes , full codes here i may edit it for you!!
Reply
#5

He means -
He want to make a .txt file that saves /setvip log
Reply
#6

Код:
LogPromotions(playerid, targetid, vipLevel, bool: promotion = false)
{
	new File:file;
	if(!fexist("promotion_logs.txt")) // name of the file you want => will be created under scriptfiles folder
	{
		file = fopen("promotion_logs.txt", io_write);
	}
	else
	{
		file = fopen("promotion_logs.txt", io_append);
	}
	if(file)
	{
		new logData[124];

		if(promotion)
			format(logData, sizeof(logData),"[PROMOTED]: Admin %s has promoted %s to %d level\r\n", GetName(playerid), GetName(targetid), vipLevel);
		else
			format(logData, sizeof(logData),"[DEMOTED]: Admin %s has demoted %s to %d level\r\n", GetName(playerid), GetName(targetid), vipLevel);
		
		fwrite(file, logData);
		fclose(file);
	}
	return 1;
}

stock GetName(playerid)
{
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, MAX_PLAYER_NAME);
	return name;
}

CMD:setvip(playerid, params[])
{
	if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, RCONERROR);
    {
		if(PlayerInfo[playerid][pVipLevel] == 1) { vrank = "Bronze V.I.P"; }
		else if(PlayerInfo[playerid][pVipLevel] == 2) { vrank = "Silver V.I.P"; }
		else if(PlayerInfo[playerid][pVipLevel] == 3) { vrank = "Gold V.I.P"; }
		{
			new victimname[MAX_PLAYER_NAME], vipname[MAX_PLAYER_NAME], viplevel, giveplayerid, string[128];
			if(sscanf(params, "ui", giveplayerid, viplevel)) return SendClientMessage(playerid, COLOR_DGRAY, "Syntax: /setvip [playerid] [level]");
			if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected");
			if(viplevel > 3 || viplevel < 0) return SendClientMessage(playerid, COLOR_RED, "ERROR: Valid levels: 1-3");
			PlayerInfo[giveplayerid][pVipLevel] = viplevel;
			GetPlayerName(giveplayerid, victimname, sizeof(victimname));
			GetPlayerName(playerid, vipname, sizeof(vipname));
			PlayerInfo[giveplayerid][pVipLevel] = viplevel;
			GetPlayerName(giveplayerid, victimname, sizeof(victimname));
			GetPlayerName(playerid, vipname, sizeof(vipname));
			
			format(string,sizeof(string),"Administrator %s(%d) has set you to VIP Status! [Level: %i]", vipname, playerid, viplevel, giveplayerid);
			SendClientMessage(playerid, COLOR_AQUA, string);
			format(string, sizeof(string), ">> You set %s(%d) VIP level to '%i'", victimname, playerid, viplevel, giveplayerid);
			SendClientMessage(playerid, COLOR_DGRAY, string);

			if(viplevel > PlayerInfo[giveplayerid][pVipLevel]) // promoted <<
				LogPromotions(playerid, giveplayerid, viplevel, true);
			else
				LogPromotions(playerid, giveplayerid, viplevel);
		}
    }
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)