Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define notafkdialog 1
- #define leuchtgruen 0x9ACD32AA
- #define grau 0xB4B5B7FF
- #define gruen 0x33AA33AA
- #define leuchtrot 0xFF6347AA
- #define leuchtblau 0x33CCFFAA
- #define gelb 0xFFFF00AA
- #define rot 0xAA3333AA
- new Text:NOTAFK1,Text:NOTAFKCODE,Text:NOTAFK2,AFKKICK[MAX_PLAYERS],Code[MAX_PLAYERS],Float:PlayerPos[MAX_PLAYERS][6];
- new idletimer = 900000; //10 min.
- forward AFKOn(playerid);
- forward IdleKick();
- forward KickAFK(playerid);
- //GameModeInit
- NOTAFK1 = TextDrawCreate(277.000000, 133.000000, "~r~AFK-System");
- TextDrawBackgroundColor(NOTAFK1, 255);
- TextDrawFont(NOTAFK1, 1);
- TextDrawLetterSize(NOTAFK1, 0.390000, 1.699999);
- TextDrawColor(NOTAFK1, -1);
- TextDrawSetOutline(NOTAFK1, 0);
- TextDrawSetProportional(NOTAFK1, 1);
- TextDrawSetShadow(NOTAFK1, 1);
- NOTAFKCODE = TextDrawCreate(168.000000, 133.000000, " ");
- TextDrawBackgroundColor(NOTAFKCODE, 255);
- TextDrawFont(NOTAFKCODE, 1);
- TextDrawLetterSize(NOTAFKCODE, 0.390000, 1.699999);
- TextDrawColor(NOTAFKCODE, -1);
- TextDrawSetOutline(NOTAFKCODE, 0);
- TextDrawSetProportional(NOTAFKCODE, 1);
- TextDrawSetShadow(NOTAFKCODE, 1);
- TextDrawUseBox(NOTAFKCODE, 1);
- TextDrawBoxColor(NOTAFKCODE, 150);
- TextDrawTextSize(NOTAFKCODE, 462.000000, 0.000000);
- NOTAFK2 = TextDrawCreate(230.000000, 178.000000, "~y~Du hast 60 Sekunden Zeit.");
- TextDrawBackgroundColor(NOTAFK2, 255);
- TextDrawFont(NOTAFK2, 1);
- TextDrawLetterSize(NOTAFK2, 0.390000, 1.699999);
- TextDrawColor(NOTAFK2, -1);
- TextDrawSetOutline(NOTAFK2, 0);
- TextDrawSetProportional(NOTAFK2, 1);
- TextDrawSetShadow(NOTAFK2, 1);
- //OnPlayerConnect
- TextDrawHideForPlayer(playerid, NOTAFK1);
- TextDrawHideForPlayer(playerid, NOTAFKCODE);
- TextDrawHideForPlayer(playerid, NOTAFK2);
- AFKKICK[playerid] = 1;
- Code[playerid] = 0;
- //CommandText
- //Admin Abfrage erfolgt über /rcon login ob eingeloggt oder nicht
- if(strcmp(cmd,"/notafk",true) == 0)
- {
- if(AFKKICK[playerid] == 1)
- {
- SendClientMessage(playerid, grau,"Du stehst nicht unter AFK verdacht!");
- return 1;
- }
- if(AFKKICK[playerid] == 0)
- {
- format(string,sizeof(string),"Du wurdest vom System als AFK anerkannt.\nGib hier deinen Code ein.");
- ShowPlayerDialog(playerid, notafkdialog,DIALOG_STYLE_INPUT,"AFK-System Code Eingabe",string,"Absenden","Abbruch");
- return 1;
- }
- return 1;
- }
- if(strcmp(cmd, "/afk", true) == 0)
- {
- if(IsPlayerAdmin(playerid))
- {
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, grau, "* /afk [playerid]");
- return 1;
- }
- giveplayerid = ReturnUser(tmp);
- if(IsPlayerConnected(giveplayerid))
- {
- if(giveplayerid != INVALID_PLAYER_ID)
- {
- SendClientMessage(playerid, leuchtblau,"* Du hast den Spieler Erfolgreich auf AFK überprüft!");
- AFKOn(giveplayerid);
- return 1;
- }
- }
- }
- else
- {
- SendClientMessage(playerid, grau, "Du bist nicht der Projektleiter/Administrator.");
- }
- return 1;
- }
- //DialogResponse
- if(dialogid == notafkdialog)
- {
- if(response == 0)
- {
- return 1;
- }
- if(response == 1)
- {
- if(Code[playerid] == strval(inputtext))
- {
- SendClientMessage(playerid, leuchtblau,"* Anwesenheit bestätigt.");
- AFKKICK[playerid] = 1;
- TextDrawHideForPlayer(playerid, NOTAFK1);
- TextDrawHideForPlayer(playerid, NOTAFKCODE);
- TextDrawHideForPlayer(playerid, NOTAFK2);
- return 1;
- }
- else
- {
- format(string,sizeof(string),"Falscher Code!\nDu musst den richtigen Code hier eingeben! ({F3FF02}%d{FFFFFF})",Code[playerid]);
- ShowPlayerDialog(playerid, notafkdialog,DIALOG_STYLE_INPUT,"AFK-System Code Eingabe",string,"Absenden","Abbruch");
- }
- }
- }
- public AFKOn(playerid)
- {
- if(IsPlayerConnected(playerid) && AFKKICK[playerid] == 1)
- {
- new string[250];
- SetCodeArray(playerid);
- AFKKICK[playerid] = 0;
- SetTimerEx("KickAFK",60000,0,"i",playerid);
- format(string,255,"~n~~w~Du stehst im Verdacht, AFK zu sein. Wenn du~n~ nicht AFK bist, gib ~g~/notafk %d~w~ ein.~n~",Code[playerid]);
- TextDrawSetString(NOTAFKCODE, string);
- TextDrawShowForPlayer(playerid, NOTAFK1);
- TextDrawShowForPlayer(playerid, NOTAFKCODE);
- TextDrawShowForPlayer(playerid, NOTAFK2);
- }
- return 1;
- }
- public IdleKick()
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(IsPlayerAdmin(i))
- {
- GetPlayerPos(i, PlayerPos[i][0], PlayerPos[i][1], PlayerPos[i][2]);
- if(PlayerPos[i][0] == PlayerPos[i][3] && PlayerPos[i][1] == PlayerPos[i][4] && PlayerPos[i][2] == PlayerPos[i][5])
- {
- AFKOn(i);
- }
- PlayerPos[i][3] = PlayerPos[i][0];
- PlayerPos[i][4] = PlayerPos[i][1];
- PlayerPos[i][5] = PlayerPos[i][2];
- }
- }
- }
- }
- public KickAFK(playerid)
- {
- if(AFKKICK[playerid] == 0)
- {
- SendClientMessage(playerid, leuchtrot,"Du wurdest gekickt (AFK)");
- Kick(playerid);
- return 1;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment