problem with afk with score system ;S
#1

Hello i have problem with that system... players get too fast score it wont give 1 score in 1 minute it gives more
PHP код:
//==============================================================================
//                             -> Includes <-
//==============================================================================
#include <a_samp>
#include <JunkBuster>
//==============================================================================
//                             -> Script Colors <-
//==============================================================================
#define RED        0xFF0000FF
#define GREEN   0x009500AA
#define GREEN2  0x00DD00AA
#define GREY    0xAEAEAEA4
//==============================================================================
//                             -> Configuration <-
//                  true - Enable | false - Disable
//==============================================================================
#define AutoAfk          true  //Enable/disable Player Automatically come into AFK mode after Delay.
#define AutoKick          true  //Enable/disable Player Automatically Kick into AFK mode after Delay.
#define Music              true  //Enable/disable Players listen Music in AFK Mode.
#define RotationCam       true  //Enable/disable Players Rotating Camera in AFK Mode
#define SaveAfkLog      false  //Enable/disable Save in Log file players who Entered and Left the AFK Mode
#define AfkSecondMsg    true  //Enable/Disable The textdraw that Indicates the time that the player are in AFK Mode
#define UseOneLog       false //Enable/disable Save in ONE Log file players who Entered and Left the AFK Mode
#define AutoAfk_Delay   60    //Seconds before player enter in AFK Mode (If it does not move, and the 'AutoAfk' is enabled)(Not Below 30)
#define AutoKick_Delay  600  //Seconds before kicking AFK Players (If 'AutoKick is enabled) (Not Below 60)
//==============================================================================
enum Info
{
    
ObjBed,
    
tTime,
    
AfkTime,
    
bool:InAfk,
    
Float:Pos[4],
    
key[3],
    
pName[24],
    
bool:pSpawned,
};
new 
LpInfo[MAX_PLAYERS][Info];
new    
Float:MoveCam 0.0;
new 
Text:TextAfkMsg[MAX_PLAYERS];
new 
Text:TextTimer[MAX_PLAYERS];
new 
lstring[80];
new 
TimerString[120];
new 
ScoreTimer;
enum Config
{
    
LAutoAFK_Time,
    
LAutoKick_Time,
    
LMusic,
    
LAutoAFK,
    
LAutoKick,
    
LRotoCam
};
new    
LConfig[Config];
new    
Musics_IDs[] = {
10681183107610971068,
11851187106211851187,
10971097,10621068
};
new 
Dances_IDs[][]    = {
"DAN_Loop_A","dnce_M_a","dnce_M_c"
};
forward GiveScore(playerid);
forward UpdateAfkSystem();
//==============================================================================
//                             -> ScriptInit <-
//==============================================================================
public OnFilterScriptInit()
{
    
UpdateConfiguration();
    
LoadTextDraws();
    
MoveCam 100/4000.0;
    
SetTimer("UpdateAfkSystem"100true);
    
ScoreTimer SetTimer("GiveScore"60000true); 
}
//==============================================================================
//                             -> ScriptExit <-
//==============================================================================
public OnFilterScriptExit()
{
    for(new 
ii<MAX_PLAYERSi++)
    
TextDrawHideForPlayer(iTextTimer[i]);
    return 
1;
}
//==============================================================================
//                             -> Player Connect <-
//==============================================================================
public OnPlayerConnect(playerid)
{
    
ResetPInfo(playerid);
    
LoadAnims(playerid);
    return 
true;
}
//==============================================================================
//                             -> Player Spawn <-
//==============================================================================
public OnPlayerSpawn(playerid)
{
    
LpInfo[playerid][pSpawned] = true;
    return 
true;
}
//==============================================================================
//                             -> Player Death <-
//==============================================================================
public OnPlayerDeath(playeridkilleridreason)
{
    
LpInfo[playerid][pSpawned] = false;
    return 
true;
}
//==============================================================================
//                                 -> Commands <-
//==============================================================================
public OnPlayerCommandText(playeridcmdtext[])
{
//======================
// AFK LIST
//======================
    
if(strcmp("/afklist"cmdtexttrue7) == 0)
    {
        for(new 
0MAX_PLAYERSi++)
        {
            if(
IsPlayerConnected(i))
            {
                
SendClientMessage(playerid0x009E00AA"____________|- AFK Players -|____________");
                if(!
LpInfo[i][InAfk]) {
                 return 
SendClientMessage(playeridRED"In moment any players is on Afk Mode!");
                }
                if(
LpInfo[i][InAfk])
                {
                    new 
PlayerName[MAX_PLAYER_NAME];
                    
GetPlayerName(iPlayerNameMAX_PLAYER_NAME);
                    
format(lstring256"Player: \"%s\" | ID: %d"PlayerNamei);
                    
SendClientMessage(playeridGREEN2lstring);
                     }
                }
            }
        return 
1;
        }
//======================
// AFK
//======================
    
if(!strcmp(cmdtext"/afk"))
    {
        if(
LpInfo[playerid][pSpawned])
        
EnterInAfk(playerid);
        else
        
SendClientMessage(playeridRED"|- AFK Error: You are not Spawned! -|");
        return 
true;
    }
    else if(
LpInfo[playerid][InAfk])
    return 
true;
    return 
false;
}
public 
OnPlayerText(playeridtext[])
{
    if(
LpInfo[playerid][InAfk])
    return 
false;
    return 
true;
    
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
newkeys == 16 && LpInfo[playerid][InAfk])
    
EnterInAfk(playerid);
}
//==============================================================================
//                                 -> Update AFK <-
//==============================================================================
public UpdateAfkSystem()
{
    for(new 
0GetMaxPlayers(); ji++)
    {
        if(
IsPlayerConnected(i) && LpInfo[i][pSpawned])
        {
            
GetPlayerKeys(i,LpInfo[i][key][0],LpInfo[i][key][1],LpInfo[i][key][2]);
            
            if(
LpInfo[i][key][0] + LpInfo[i][key][1] + LpInfo[i][key][2] == && !LpInfo[i][InAfk])
            {
               
LpInfo[i][AfkTime] ++;
               if(
LpInfo[i][AfkTime] == LConfig[LAutoAFK_Time])
            
EnterInAfk(i);
            }
            else 
LpInfo[i][AfkTime] = 0;
            if (
LpInfo[i][InAfk])
            {
            
UpdateTextDraw(i);
            if(
LConfig[LRotoCam])
            
RotAfkCam(i);
            }
        }
    }
}
//==============================================================================
//                             -> Camera Rotating <-
//==============================================================================
RotAfkCam(playerid)
{
    
    
LpInfo[playerid][Pos][3] += MoveCam;
    
SetPlayerCameraPos(playerid,
    
    
LpInfo[playerid][Pos][0] + floatcos(LpInfo[playerid][Pos][3])*5,
     
LpInfo[playerid][Pos][1] + floatsin(LpInfo[playerid][Pos][3])*5,
     
LpInfo[playerid][Pos][2] + 1);
    
SetPlayerCameraLookAt(playerid,LpInfo[playerid][Pos][0], LpInfo[playerid][Pos][1],LpInfo[playerid][Pos][2] + 0.5);
}
//==============================================================================
//                             -> Player Enter in AFK <-
//==============================================================================
EnterInAfk(playerid)
{
    
LpInfo[playerid][InAfk] = !LpInfo[playerid][InAfk];
    
GetPlayerName(playeridLpInfo[playerid][pName], 24);
    if(
LpInfo[playerid][InAfk])
    {
        
//======================
        // Enter
        //======================
        #if AfkSecondMsg == true
        
GameTextForPlayer(playerid,"~w~~n~~n~~n~~n~~n~~n~~n~Type ~b~ENTER ~w~or ~g~/afk ~w~to exit",2000,3);
        
#endif
        
format(lstring,sizeof(lstring),"|- \"%s\" is in AFK Mode! (Busy/Unavailable) -|",LpInfo[playerid][pName]);
        
SendClientMessageToAll(GREENlstring);
        
format(lstring,sizeof(lstring),"Player \"%s\" has entered in AFK Mode!",LpInfo[playerid][pName]);
        
#if UseOneLog == true
        
SaveLog("AfkLog",lstring);
        
#else
        
SaveLog("EnteredAfkLog",lstring);
        
#endif
        
strins(LpInfo[playerid][pName],"[AFK]",0);
        
SetPlayerName(playeridLpInfo[playerid][pName]);
        
TogglePlayerControllable(playeridfalse);
        
KillTimer(ScoreTimer);
        
GetPlayerPos(playerid,LpInfo[playerid][Pos][0],LpInfo[playerid][Pos][1], LpInfo[playerid][Pos][2]);
        
GetPlayerFacingAngle(playeridLpInfo[playerid][Pos][3]);
        for(new 
i=0i<MAX_PLAYERSi++)
        {
        
TextDrawShowForPlayer(iTextTimer[i]);
        
TextDrawShowForPlayer(iTextAfkMsg[i]);
        }
        
LpInfo[playerid][tTime] = GetTickCount();
        
AfkEffects(playeridtrue);
        
//======================
    
}
    else
    {
        
//======================
        // Exit
        //======================
        
strdel(LpInfo[playerid][pName], 05);
        
SetPlayerName(playeridLpInfo[playerid][pName]);
        
format(lstring,sizeof(lstring),"|- \"%s\" have Returned to Game! (Online) -|",LpInfo[playerid][pName]);
        
SendClientMessageToAll(GREEN2lstring);
        
format(lstring,sizeof(lstring),"Player \"%s\" has exited the AFK Mode!",LpInfo[playerid][pName]);
        
#if UseOneLog == true
        
SaveLog("AfkLog",lstring);
        
#else
        
SaveLog("ExitedAfkLog",lstring);
        
#endif
        
TogglePlayerControllable(playeridtrue);
        
ScoreTimer SetTimer("GiveScore"60000true);
        
SetCameraBehindPlayer(playerid);
        for(new 
i=0i<MAX_PLAYERSi++)
        {
        
TextDrawHideForPlayer(iTextTimer[i]);
        
TextDrawHideForPlayer(iTextAfkMsg[i]);
        }
        
LpInfo[playerid][tTime] = 0;
        
AfkEffects(playeridfalse);
        
        
//======================
    
}
}
//==============================================================================
//                         -> Save in Log - Players in AFK <-
//==============================================================================
SaveLog(logname[],text[])
{
    
#if SaveAfkLog == true
    
new File:Lfile;
    new 
filepath[256];
    new 
string[256];
    new 
year,month,day;
    new 
hour,minute,second;
    
getdate(year,month,day);
    
gettime(hour,minute,second);
    
format(filepath,sizeof(filepath),"Afk/%s.txt",logname);
    
Lfile fopen(filepath,io_append);
    
format(string,sizeof(string),"[%02d/%02d/%02d | %02d:%02d:%02d] %s\r\n",day,month,year,hour,minute,second,text);
    
fwrite(Lfile,string);
    
fclose(Lfile);
    
#endif
    
return 1;
}
//==============================================================================
//                         -> Afk Effects (Anims & Musics) <-
//==============================================================================
AfkEffects(playeridbool:toggle)
{
    if (
toggle)
    {
        if (
LConfig[LMusic])
        
PlayerPlaySound(playerid,Musics_IDs[random(sizeof(Musics_IDs))], 0.0,0.0,0.0);
        if (!
IsPlayerInAnyVehicle(playerid))
        {
            switch(
random(6))
            {
                case 
0:
                {
                
ApplyAnimation(playerid,"INT_HOUSE","BED_Loop_R",4.0,1,0,0,0,0);
                
LpInfo[playerid][ObjBed] = CreateObject(1771,LpInfo[playerid][Pos][0],LpInfo[playerid][Pos][1],LpInfo[playerid][Pos][2]-0.48,0.0,0.0,LpInfo[playerid][Pos][3]+75.0);
                }
                case 
1:
                
ApplyAnimation(playerid,"ped","cower",3.0,1,0,0,0,0);
                case 
2:
                
ApplyAnimation(playerid,"BEACH","bather",4.0,1,0,0,0,0);
                case 
3:
                
ApplyAnimation(playerid,"DANCING",Dances_IDs[random(sizeof(Dances_IDs))],4.0,1,0,0,0,0);
                case 
4:
                
ApplyAnimation(playerid,"COP_AMBIENT","Coplook_loop",4.0,0,1,1,1,-1);
                case 
5:
                
ApplyAnimation(playerid,"BEACH","ParkSit_M_loop",4.0,1,0,0,0,0);
            }
        }
    }
    else
    {
        
ApplyAnimation(playerid"CARRY""crry_prtial"4.000000);
        if (
LConfig[LMusic])
        
PlayerPlaySound(playerid10630.0,0.0,0.0);
        if (
IsValidObject(LpInfo[playerid][ObjBed]))
        {
        
DestroyObject(LpInfo[playerid][ObjBed]);
        
LpInfo[playerid][ObjBed] = 0;
        }
    }
}
//==============================================================================
//                         -> Reset Player AFK Stats <-
//==============================================================================
ResetPInfo(playerid)
{
    
LpInfo[playerid][InAfk]        = false;
    
LpInfo[playerid][pSpawned]    = false;
    
LpInfo[playerid][tTime]        = 0;
    
LpInfo[playerid][AfkTime]    = 0;
    
LpInfo[playerid][ObjBed]    = 0;
}
//==============================================================================
//                         -> Update Timer TextDraw <-
//==============================================================================
UpdateTextDraw(playerid)
{
    new 
Time floatround((GetTickCount() - LpInfo[playerid][tTime]) / 1000),
    
Secs Time 60,
    
Mins floatround((Time/60), floatround_floor),
    
KickTime floatround(LConfig[LAutoKick_Time] - Time);
    
    
format(lstringsizeof(lstring), "~g~%02d:%02d",MinsSecs);
    
TextDrawSetString(TextTimer[playerid], lstring);
    
    if (
LConfig[LAutoKick] && KickTime <= floatround(LConfig[LAutoKick_Time]/3))
    {
        
format(lstringsizeof(lstring), "~b~AutoKick ~n~   ~r~%d",KickTime);
        
TextDrawSetString(TextTimer[playerid], lstring);
        if (
KickTime 1)
        {
            
EnterInAfk(playerid);
            
format(lstringsizeof(lstring), "|- You have been Automatically Kicked! | Reason: Exceeded %d Seconds in AFK Mode! -|",LConfig[LAutoKick_Time]);
            
SendClientMessage(playerid,RED,lstring);
            
format(lstringsizeof(lstring), "~w~~n~~n~~n~~n~Exceeded ~r~%d ~w~Seconds in ~y~AFK Mode!",LConfig[LAutoKick_Time]);
            
GameTextForPlayer(playerid,lstring,60000,3);
            
TextDrawSetString(TextAfkMsg[playerid], "You are ~r~Kicked!");
            
TextDrawShowForPlayer(playeridTextAfkMsg[playerid]);
            
TogglePlayerControllable(playeridfalse);
            for(new 
015i++)
            
SendClientMessage(playerid,0," ");
            
Kick(playerid);
            }
        }
}
//==============================================================================
//                         -> Verify and Update Configs <-
//==============================================================================
UpdateConfiguration()
{
    
LConfig[LMusic]              = Music;
    
LConfig[LRotoCam]          = RotationCam;
    
LConfig[LAutoAFK]         = AutoAfk;
    
LConfig[LAutoKick]          = AutoKick;
    
LConfig[LAutoAFK_Time]     = AutoAfk_Delay;
    
LConfig[LAutoKick_Time]     = AutoKick_Delay;
    
//----------------------
    
if(LConfig[LAutoKick_Time] < 60LConfig[LAutoKick_Time] = 60;
    if(
LConfig[LAutoAFK_Time]  < 30LConfig[LAutoAFK_Time]  = 30;
    
//----------------------
    
LConfig[LAutoAFK_Time] = floatround((LConfig[LAutoAFK_Time]*1000)/100);
}
//==============================================================================
//                         -> PreLoad TextDraws <-
//==============================================================================
LoadTextDraws()
{
    for(new 
i=0i<MAX_PLAYERSi++)
    {
    
format(TimerStringsizeof(TimerString), "  ");
    
TextTimer[i] = TextDrawCreate(300.000000122.000000TimerString);
    
TextDrawBackgroundColor(TextTimer[i], 255);
    
TextDrawFont(TextTimer[i], 1);
    
TextDrawLetterSize(TextTimer[i], 0.3400001.000000);
    
TextDrawColor(TextTimer[i], -1);
    
TextDrawSetOutline(TextTimer[i], 0);
    
TextDrawSetProportional(TextTimer[i], 1);
    
TextDrawSetShadow(TextTimer[i], 1);
    
    
TextAfkMsg[i] = TextDrawCreate(227.00000092.000000"You are in ~r~AFK!");
    
TextDrawBackgroundColor(TextAfkMsg[i], 255);
    
TextDrawFont(TextAfkMsg[i], 1);
    
TextDrawLetterSize(TextAfkMsg[i], 0.6999992.699999);
    
TextDrawColor(TextAfkMsg[i], -1);
    
TextDrawSetOutline(TextAfkMsg[i], 1);
    
TextDrawSetProportional(TextAfkMsg[i], 1);
    }
}
//==============================================================================
//                         -> PreLoad Anims <-
//==============================================================================
LoadAnims(playerid)
{
    
ApplyAnimation(playerid,"CARRY",        "null",0.0,0,0,0,0,0);
       
ApplyAnimation(playerid,"DANCING",        "null",0.0,0,0,0,0,0);
    
ApplyAnimation(playerid,"ped",            "null",0.0,0,0,0,0,0);
    
ApplyAnimation(playerid,"INT_HOUSE",    "null",0.0,0,0,0,0,0);
    
ApplyAnimation(playerid,"BEACH",        "null",0.0,0,0,0,0,0);
    
ApplyAnimation(playerid,"COP_AMBIENT",     "null" ,0.0,0,0,0,0,0);
}
//==============================================================================
public GiveScore()
{
   for(new 
i=0MAX_PLAYERSi++)
   {
      if(
IsPlayerConnected(i))
      {
            
SetPlayerScore(iGetPlayerScore(i) + 1);
      }
   }
}
// ©The LuxurioN - All Rights Reserved. 
and make it plz like that it gives score if player is in car
Reply
#2

When a player is in a car and the score still grows:

Код:
public GiveScore()
{
   for(new i=0; i < MAX_PLAYERS; i++)
   {
      if(IsPlayerConnected(i))
      {
          if(IsPlayerInAnyVehicle(i))
          {
            SetPlayerScore(i, GetPlayerScore(i) + 1);
          }
      }
   }
}
For giving less score:

You have to play with this
Код:
, 60000,
number from
Код:
ScoreTimer = SetTimer("GiveScore", 60000, true);
.

Make it 80000. If it does give a little less, then change the number to like something 100000 and eventually you will get what you want.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)