set temporary level
#1

Removed, Thanks
Reply
#2

https://sampwiki.blast.hk/wiki/SetTimerEx

Set a time to activate a different function which will set the players level back to what it was before. Make sure you save the level before in a variable. You also have to account for when the player logs out.
Reply
#3

Removed
Reply
#4

bit on the tired side so try to make sense out of what im going to try to tell you..

Ok so make a new variable thing for the players like your other one that also saves.
Код:
PlayerInfo[playerid][Tempt];
Just call it Tempt short for temp time.. ok now when you set the temporary level for the player you should set that variable above to however long to temp will be. Example

Код:
/settemplevel [PlayerID] [Level] [Time]
Pretend i use the
/settemp 0 5 10

Now i would make that so it sets it to 10 minutes... fuck it ill just script it here haha

Код:
CMD:settemplevel(playerid,params[])
{
    if(PlayerInfo[playerid][LoggedIn] == 1)
    {
        if(PlayerInfo[playerid][Level] >= 10)
        {
            new tmp [64], Index;
            new tmp2[64], new tmp2[18];;
            tmp  = strtok(params,Index);
            tmp2 = strtok(params,Index);
			tmp3 = strtok(params,Index);
            if(isnull(tmp) || isnull(tmp2) || isnull(tmp2)) return
            SendClientMessage(playerid, LIGHTBLUE2, "Usage: /settemplevel [PlayerID] [Level]");
            new player1, level, time, string[128];
            player1 = strval(tmp);
            level = strval(tmp2);
			time = strval(tmp3);

            if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
            {
                if(PlayerInfo[player1][LoggedIn] == 1)
                {
                if(level > ServerInfo[MaxAdminLevel])
                return SendClientMessage(playerid,red,"ERROR: Invalid Level!");
                if(level == PlayerInfo[player1][Level])
                return SendClientMessage(playerid,red,"ERROR: Player is already this Level");
				if(time > 181)
                return SendClientMessage(playerid,red,"ERROR: Time done in minutes!");
                CMDMessageToAdmins(playerid,"SetTempLevel");
                new year,month,day;
                new hour,minute,second;
                getdate(year, month, day);
                gettime(hour,minute,second);
				PlayerInfo[player1][Tempt] = time;
				Temp[player1] = SetTimerEx("TempTimer",60000,1,"i",player1);
                if(level > 10)
                {
                AdmRank = "Professional Admin";
                }
                switch(level)
                {
                case 1: AdmRank = "VIP 1";
                case 2: AdmRank = "VIP 2";
                case 3: AdmRank = "VIP 3";
                case 4: AdmRank = "Level 4";
                case 5: AdmRank = "Administrator";
                case 6: AdmRank = "Master Administrator";
                case 7: AdmRank = "Head Administrator";
                case 8: AdmRank = "Trusted Admin";
                case 9: AdmRank = "Level 9";
                case 10: AdmRank = "Level 10";
                }
                if(level > 0)
                format(string,sizeof(string),"* Administrator %s has Temporarily set you to Administrator Status | Level: %d - %s ", pName(playerid), level, AdmRank);
                else
                format(string,sizeof(string),"* Administrator %s has temporarily set you to Player Status | Level: %d ", pName(playerid), level);
                SendClientMessage(player1,blue,string);

                if(level > PlayerInfo[player1][Level])
                GameTextForPlayer(player1,"Promoted", 2000, 3);
                else GameTextForPlayer(player1,"Demoted", 2000, 3);

                format(string,sizeof(string),"* You have given %s Temp Level %d on '%d/%d/%d' at '%d:%d:%d' ", PlayerName2(player1), level, day, month, year, hour, minute, second);
                SendClientMessage(playerid,BlueMsg,string);
                format(string,sizeof(string),"Administrator %s has made %s temp Level %d",pName(playerid), PlayerName2(player1), level);
                SaveIn("TempAdminLog",string);
                PlayerInfo[player1][Level] = level;  //<<=== This is the problem
                return PlayerPlaySound(player1,1057,0.0,0.0,0.0);
                }
                else return SendClientMessage(playerid,red,"ERROR: Player must be registered and logged in to be admin");
            }
            else return ErrorMessages(playerid, 2);
        }
        else return ErrorMessages(playerid, 1);
    }
    else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
This is your new command. You need to add PlayerInfo[player1][Tempt] to your player save things.

Код:
new Temp[MAX_PLAYERS];
Put this at the top of your script


Код:
forward TempTimer(playerid);
public TempTimer(playerid)
{
	if(PlayerInfo[player1][Tempt] >= 1)
	{
		PlayerInfo[player1][Tempt] -1;
	}
	if(PlayerInfo[player1][Tempt] = 0)
	{
		KillTimer(Temp[playerid]);
		//You need to record his old Levels and return them to their previous state here
	}
}
This is your timer


You will need to also put under. 'OnPlayerConnect'
Код:
if(PlayerInfo[playerid][Tempt] >= 1)
{
Temp[playerid] = SetTimerEx("TempTimer",60000,1,"i",playerid);
}
So that when a player reconnects it starts to take the time away from his temp thing again

Hope you read over what i've done for ya, Good luck and sorry if i missed something
Reply
#5

Removed
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)