Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" [RaFaeL] AFK system v0.1 by zRaFaeL loaded! ");
- print("--------------------------------------\n");
- return 1;
- }
- enum eSpawns {
- animname[64],
- Float:x,
- Float:y,
- Float:z,
- Float:a
- }
- new Spawns[] [eSpawns] = {
- //{anim, x, y, z, a}
- {"dnce_M_a",-2453.0132,1145.1104,65.2344,178.8782},
- {"dnce_M_b",-2473.6882,1544.6368,36.8047,268.4924},
- {"dnce_M_c",-1954.2953,1346.4600,31.2217,179.8182}
- };
- enum eLastPos {
- Float:lx,
- Float:ly,
- Float:lz,
- Float:la
- }
- new LastPosition[MAX_PLAYERS][eLastPos];
- // Change this!
- #define COLOR_INAFK 0xFF0000FF
- #define COLOR_OUTAFK 0xFF0000FF
- new str[128];
- public OnPlayerDisconnect(playerid, reason)
- {
- SetPVarInt(playerid, "afk", 0);
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- if(GetPVarInt(playerid, "afk") >= 1) return Afk(playerid, GetPVarInt(playerid, "afk"));
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- dcmd(AFK, 3, cmdtext);
- if(GetPVarInt(playerid, "afk") >= 1) return Afk(playerid, GetPVarInt(playerid, "afk"));
- // Here commands...
- return 0;
- }
- dcmd_AFK(playerid, params[])
- {
- if(strlen(params) > 0) {
- return Afk(playerid, GetPVarInt(playerid, "afk"), params);
- } else {
- return Afk(playerid, GetPVarInt(playerid, "afk"));
- }
- }
- stock GetName(playerid) {
- GetPlayerName(playerid, str, MAX_PLAYER_NAME);
- return str;
- }
- stock Afk(playerid, afkstats, reason[] = "no-reason") {
- if(afkstats < 1) {
- SetPVarInt(playerid, "afk", 1); //Set player afk stats to 1 - true
- TogglePlayerControllable(playerid,0);
- //Save last position
- GetPlayerPos(playerid, LastPosition[playerid][lx], LastPosition[playerid][ly], LastPosition[playerid][lz]);
- GetPlayerFacingAngle(playerid, LastPosition[playerid][la]);
- //Set player to random spawn
- new spawnid = random(sizeof(Spawns));
- SetPlayerPos(playerid,Spawns[spawnid][x],Spawns[spawnid][y],Spawns[spawnid][z]);
- SetPlayerFacingAngle(playerid, Spawns[spawnid][a]);
- ApplyAnimation(playerid,"DANCING",Spawns[spawnid][animname],4.0,1,0,0,0,-1);
- format(str, sizeof(str), "The player %s is now afk(away from keyboard) [reason: %s]", GetName(playerid), reason);
- return SendClientMessageToAll(COLOR_INAFK, str);
- } else {
- SetPVarInt(playerid, "afk", 0); //Set player afk stats to 0 - false
- TogglePlayerControllable(playerid,1);
- //Set player to the last position
- SetPlayerPos(playerid, LastPosition[playerid][lx], LastPosition[playerid][ly], LastPosition[playerid][lz]);
- SetPlayerFacingAngle(playerid, LastPosition[playerid][la]);
- format(str, sizeof(str), "The player %s is now back to game", GetName(playerid));
- return SendClientMessageToAll(COLOR_OUTAFK, str);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement