Making Command only used in specific time interval. [+REP]
#1

Hello SA-MP forum,
Well, I need your help today in something, I have a command for my gamemode (RPG) which is for attacking turfs. I want to make this command only usable between 20:00 and 22:00 server time.

The one who'll help me will get [+REP]!

PHP код:
CMD:attack(playeridparams[])
{
    if(
gPlayerLogged[playerid] == 0) return SendClientMessage(playeridCOLOR_LIGHTRED"You need to login first.");
    new 
hour,minn,sec;
    
gettime(hour,minn,sec);
    if(!
IsAMember(playerid)) return SCM(playerid,COLOR_WHITE,"{FFB870}Error: You are not a member of the Mafia.");
    if(
PlayerInfo[playerid][pRank] < 3) return SCM(playerid,TEAM_AZTECAS_COLOR,"Error: You do not have rank 3.");
    new 
turf,faction,string[100],sendername[MAX_PLAYER_NAME];
    for(new 
1<= sizeof(TurfInfo); i++)
    {
        if(
IsPlayerInTurf(playeridi) == 1)
        {
            
turf i;
            break;
        }
    }
    
GetPlayerName(playeridsendernamesizeof(sendername));
    if(
turf == 0) return SCM(playeridTEAM_AZTECAS_COLOR"Error: You are not on a territory.");
    
faction PlayerInfo[playerid][pMember];
    if(
TurfInfo[turf][zOwned] == faction) return SCM(playeridTEAM_AZTECAS_COLOR"Error: You can't attack your own turf.");
    if(
WarInfo[turf][wAttacker] != 0) return SCM(playeridTEAM_AZTECAS_COLOR"Error: Turf is already attacked.");
    if(
TurfInfo[turf][zTime] > 0)
    {
        
format(string,sizeof(string),"Error: Turf can be attacked in %d hours.",TurfInfo[turf][zTime]);
        
SCM(playeridTEAM_AZTECAS_COLOR,string);
        return 
1;
    }
    if(
InWar[faction] == 1) return SCM(playeridTEAM_AZTECAS_COLOR"Error: You have an active war.");
    if(
InWar[TurfInfo[turf][zOwned]] == 1) return SCM(playeridTEAM_AZTECAS_COLOR"Error: This mafia have active war.");
    
TurfInfo[turf][zTime] = 24;
    new 
str[128];
    
format(str,128,"UPDATE `turfs` SET `Time`='24' WHERE `ID`='%d'",turf);
    
mysql_query(SQL,str);
    
WarInfo[turf][wTime] = 900;
    
WarInfo[turf][wAttacker] = faction;
    
WarInfo[turf][wFaction] = TurfInfo[turf][zOwned];
    
format(string,sizeof(string),"Your mafia (%s) attacked turf %d owned by %s",sendername,turf,NumeFactiune(TurfInfo[turf][zOwned]));
    
SendFamilyMessage(faction,TEAM_AZTECAS_COLOR,string);
    
format(string,sizeof(string),"Turf %d, Time remaining: %s",turf,CalculeazaTimp(WarInfo[turf][wTime]));
    
SendFamilyMessage(faction,TEAM_AZTECAS_COLOR,string);
    
format(string,sizeof(string),"%s (%s) attacked your turf %d",NumeFactiune(WarInfo[turf][wAttacker]),sendername,turf);
    
SendFamilyMessage(TurfInfo[turf][zOwned],TEAM_AZTECAS_COLOR,string);
    
format(string,sizeof(string),"Turf %d, Time remaining: %s",turf,CalculeazaTimp(WarInfo[turf][wTime]));
    
SendFamilyMessage(TurfInfo[turf][zOwned],TEAM_AZTECAS_COLOR,string);
    
worstscoreat[turf] = 0;
    
worstmemberat[turf] = 999;
    
bestscoreat[turf] = 0;
    
bestmemberat[turf] = 999;
    
worstscoredf[turf] = 0;
    
worstmemberdf[turf] = 999;
    
bestscoredf[turf] = 0;
    
bestmemberdf[turf] = 999;
    
InWar[TurfInfo[turf][zOwned]] = 1;
    
InWar[faction] = 1;
    return 
1;

Reply
#2

******
Reply
#3

PHP код:
CMD:attack(playeridparams[]) 

    if(
gPlayerLogged[playerid] == 0) return SendClientMessage(playeridCOLOR_LIGHTRED"You need to login first."); 
    new 
hour,minn,sec
    
gettime(hour,minn,sec);
    if(
hour<20 || hour>22) return SendClientMessage(playerid, -1"You cannot attack now.");
    if(!
IsAMember(playerid)) return SCM(playerid,COLOR_WHITE,"{FFB870}Error: You are not a member of the Mafia."); 
    if(
PlayerInfo[playerid][pRank] < 3) return SCM(playerid,TEAM_AZTECAS_COLOR,"Error: You do not have rank 3."); 
    new 
turf,faction,string[100],sendername[MAX_PLAYER_NAME]; 
    for(new 
1<= sizeof(TurfInfo); i++) 
    { 
        if(
IsPlayerInTurf(playeridi) == 1
        { 
            
turf i
            break; 
        } 
    } 
    
GetPlayerName(playeridsendernamesizeof(sendername)); 
    if(
turf == 0) return SCM(playeridTEAM_AZTECAS_COLOR"Error: You are not on a territory."); 
    
faction PlayerInfo[playerid][pMember]; 
    if(
TurfInfo[turf][zOwned] == faction) return SCM(playeridTEAM_AZTECAS_COLOR"Error: You can't attack your own turf."); 
    if(
WarInfo[turf][wAttacker] != 0) return SCM(playeridTEAM_AZTECAS_COLOR"Error: Turf is already attacked."); 
    if(
TurfInfo[turf][zTime] > 0
    { 
        
format(string,sizeof(string),"Error: Turf can be attacked in %d hours.",TurfInfo[turf][zTime]); 
        
SCM(playeridTEAM_AZTECAS_COLOR,string); 
        return 
1
    } 
    if(
InWar[faction] == 1) return SCM(playeridTEAM_AZTECAS_COLOR"Error: You have an active war."); 
    if(
InWar[TurfInfo[turf][zOwned]] == 1) return SCM(playeridTEAM_AZTECAS_COLOR"Error: This mafia have active war."); 
    
TurfInfo[turf][zTime] = 24
    new 
str[128]; 
    
format(str,128,"UPDATE `turfs` SET `Time`='24' WHERE `ID`='%d'",turf); 
    
mysql_query(SQL,str); 
    
WarInfo[turf][wTime] = 900
    
WarInfo[turf][wAttacker] = faction
    
WarInfo[turf][wFaction] = TurfInfo[turf][zOwned]; 
    
format(string,sizeof(string),"Your mafia (%s) attacked turf %d owned by %s",sendername,turf,NumeFactiune(TurfInfo[turf][zOwned])); 
    
SendFamilyMessage(faction,TEAM_AZTECAS_COLOR,string); 
    
format(string,sizeof(string),"Turf %d, Time remaining: %s",turf,CalculeazaTimp(WarInfo[turf][wTime])); 
    
SendFamilyMessage(faction,TEAM_AZTECAS_COLOR,string); 
    
format(string,sizeof(string),"%s (%s) attacked your turf %d",NumeFactiune(WarInfo[turf][wAttacker]),sendername,turf); 
    
SendFamilyMessage(TurfInfo[turf][zOwned],TEAM_AZTECAS_COLOR,string); 
    
format(string,sizeof(string),"Turf %d, Time remaining: %s",turf,CalculeazaTimp(WarInfo[turf][wTime])); 
    
SendFamilyMessage(TurfInfo[turf][zOwned],TEAM_AZTECAS_COLOR,string); 
    
worstscoreat[turf] = 0
    
worstmemberat[turf] = 999
    
bestscoreat[turf] = 0
    
bestmemberat[turf] = 999
    
worstscoredf[turf] = 0
    
worstmemberdf[turf] = 999
    
bestscoredf[turf] = 0
    
bestmemberdf[turf] = 999
    
InWar[TurfInfo[turf][zOwned]] = 1
    
InWar[faction] = 1
    return 
1

Reply
#4

Quote:
Originally Posted by F1N4L
Посмотреть сообщение
******
Bump xD, Just reply and Not Give Solution.
Reply
#5

Did my code work?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)