Toll gate CMD
#1

hello guys i have a toll gate system. There's a cmd through which gates can be locked/unlocked but right now any faction/family member and admins can do it but i want that only RCON admin must be able to unlock/lock i mean only rcon admin can use this CMD please tell me how to make it only rcon admins?
PHP код:
public ycmd_toll(playeridcmdtext[])
{
    
#if TollFS == 0
        
if(cmdtext[0] == 1cmdtext[0] = 0;
        if(!
gPlayerLogged[playerid])
        {
            
SendClientMessage(playeridCOLOR_RED"You are not logged in.");
            return 
1;
        }
    
#endif
    
new idx,
        
L_sz_Input[256],
        
L_sz_CopName[MAX_PLAYER_NAME],
        
L_sz_MessageString[256],
        
L_sz_Rank[56],
        
L_sz_Faction[8];
    
#if TollFS == 0
        
if(!PolicePermission(playerid))
        {
            
SendClientMessage(playeridCOLOR_RED"You're not a cop, cowboy.");
            return 
1;
        }
        
format(L_sz_Rank56"%s"FactionRank(PlayerInfo[playerid][pFamily], PlayerInfo[playerid][pFamilyRank]));
        
format(L_sz_Faction8"%s"FactionInfo[PlayerInfo[playerid][pFamily]][fName]);
    
#else
        
format(L_sz_Rank56"Rank");
        
format(L_sz_Faction8"Faction");
        
strtok(cmdtextidx);
    
#endif
    
format(L_sz_CopNameMAX_PLAYER_NAMEGetICName(playerid));
    
L_sz_Input strtok(cmdtextidx);
    if(
IsNull(L_sz_Input))
    {
        
SendClientMessage(playeridCOLOR_YELLOW"Toll barrier command central for Los Santos");
        
SendClientMessage(playeridCOLOR_GRAD2"emergency/release - (Un)Locks all the barriers.");
        
SendClientMessage(playeridCOLOR_GRAD2"flint - (Un)locks flint tolls.");
        
SendClientMessage(playeridCOLOR_GRAD2"richman - (Un)locks Richman tunnel tolls.");
        
SendClientMessage(playeridCOLOR_GRAD2"lv - (Un)locks the Las Venturas Highway tolls.");
        return 
1;
    }
    if(!
Toll_TimePassedCops(playerid))
        return 
1;
    if(
strcmp(L_sz_Input"emergency"truestrlen(L_sz_Input)) == 0)
    {
        
aTolls[FlintToll][E_tLocked] = 1;
        
aTolls[RichmanToll][E_tLocked] = 1;
        
aTolls[LVToll][E_tLocked] = 1;
        
Toll_CloseToll(FlintToll);
        
Toll_CloseToll(RichmanToll);
        
Toll_CloseToll(LVToll);
        new 
L_i_Time = (GetUnixTime() + TollTimerEmergency);
        
aTolls[FlintToll][E_tTimer] = L_i_Time;
        
aTolls[RichmanToll][E_tTimer] = L_i_Time;
        
aTolls[LVToll][E_tTimer] = L_i_Time;
        
format(L_sz_MessageString256"** HQ Announcement: All toll booths were LOCKED by %s %s (%s)! **"L_sz_RankL_sz_CopNameL_sz_Faction);
        
SendTeamTypeMessage(1TEAM_BLUE_COLORL_sz_MessageString);
    }
    else if(
strcmp(L_sz_Input"release"truestrlen(L_sz_Input)) == 0)
    {
        
aTolls[FlintToll][E_tLocked] = 0;
        
aTolls[RichmanToll][E_tLocked] = 0;
        
aTolls[LVToll][E_tLocked] = 0;
        
format(L_sz_MessageString256"** HQ Announcement: All toll booths were UNLOCKED by %s %s (%s)! **"L_sz_RankL_sz_CopNameL_sz_Faction);
        
SendTeamTypeMessage(1TEAM_BLUE_COLORL_sz_MessageString);
    }
    else if(
strcmp(L_sz_Input"flint"truestrlen(L_sz_Input)) == 0)
    {
        if(
aTolls[FlintToll][E_tLocked] == 0)
        {
            
aTolls[FlintToll][E_tLocked] = 1;
            
aTolls[FlintToll][E_tTimer] = (GetUnixTime() + TollTimer);
            
Toll_CloseToll(FlintToll);
            
format(L_sz_MessageString256"** HQ Announcement: Toll booths at Flint County were LOCKED by %s %s (%s). **"L_sz_RankL_sz_CopNameL_sz_Faction);
            
SendTeamTypeMessage(1TEAM_BLUE_COLORL_sz_MessageString);
        }
        else
        {
            
aTolls[FlintToll][E_tLocked] = 0;
            
format(L_sz_MessageString256"** HQ Announcement: Toll booths at Flint County were UNLOCKED by %s %s (%s). **"L_sz_RankL_sz_CopNameL_sz_Faction);
            
SendTeamTypeMessage(1TEAM_BLUE_COLORL_sz_MessageString);
        }
    }
    else if(
strcmp(L_sz_Input"richman"truestrlen(L_sz_Input)) == 0)
    {
        if(
aTolls[RichmanToll][E_tLocked] == 0)
        {
            
aTolls[RichmanToll][E_tLocked] = 1;
            
aTolls[RichmanToll][E_tTimer] = (GetUnixTime() + TollTimer);
            
Toll_CloseToll(RichmanToll);
            
format(L_sz_MessageString256"** HQ Announcement: Toll booths at Richman were LOCKED by %s %s (%s). **"L_sz_RankL_sz_CopNameL_sz_Faction);
            
SendTeamTypeMessage(1TEAM_BLUE_COLORL_sz_MessageString);
        }
        else
        {
            
aTolls[RichmanToll][E_tLocked] = 0;
            
format(L_sz_MessageString256"** HQ Announcement: Toll booths at Richman were UNLOCKED by %s %s (%s). **"L_sz_RankL_sz_CopNameL_sz_Faction);
            
SendTeamTypeMessage(1TEAM_BLUE_COLORL_sz_MessageString);
        }
    }
    else if(
strcmp(L_sz_Input"lv"true) == 0)
    {
        if(
aTolls[LVToll][E_tLocked] == 0)
        {
            
aTolls[LVToll][E_tLocked] = 1;
            
aTolls[LVToll][E_tTimer] = (GetUnixTime() + TollTimer);
            
Toll_CloseToll(LVToll);
            
format(L_sz_MessageString256"** HQ Announcement: Toll booths at Las Venturas were LOCKED by %s %s (%s). **"L_sz_RankL_sz_CopNameL_sz_Faction);
            
SendTeamTypeMessage(1TEAM_BLUE_COLORL_sz_MessageString);
        }
        else
        {
            
aTolls[LVToll][E_tLocked] = 0;
            
format(L_sz_MessageString256"** HQ Announcement: Toll booths at Las Venturas were UNLOCKED by %s %s (%s). **"L_sz_RankL_sz_CopNameL_sz_Faction);
            
SendTeamTypeMessage(1TEAM_BLUE_COLORL_sz_MessageString);
        }
    }
    return 
1;

Thanks in advance! and who so ever fix it gets +rep!
Reply
#2

You want only rcon admin can open these gates?

you want to remove it for other factions and teams like cop?
Reply
#3

Quote:
Originally Posted by MBilal
Посмотреть сообщение
You want only rcon admin can open these gates?

you want to remove it for other factions and teams like cop?
yes, i want to remove for other teams/cops/faction i just want RCON admins to be able to use this cmd.
Reply
#4

Код:
public ycmd_toll(playerid, cmdtext[])
{
    #if TollFS == 0
        if(cmdtext[0] == 1) cmdtext[0] = 0;

        if(!gPlayerLogged[playerid])
        {
            SendClientMessage(playerid, COLOR_RED, "You are not logged in.");
            return 1;
        }
    #endif
    if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,-1,"You're not rcon admin.");
    new idx,
        L_sz_Input[256],
        L_sz_MessageString[256],
    	L_sz_Input = strtok(cmdtext, idx);

    if(IsNull(L_sz_Input))
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Toll barrier command central for Los Santos");
        SendClientMessage(playerid, COLOR_GRAD2, "emergency/release - (Un)Locks all the barriers.");
        SendClientMessage(playerid, COLOR_GRAD2, "flint - (Un)locks flint tolls.");
        SendClientMessage(playerid, COLOR_GRAD2, "richman - (Un)locks Richman tunnel tolls.");
        SendClientMessage(playerid, COLOR_GRAD2, "lv - (Un)locks the Las Venturas Highway tolls.");
        return 1;
    }

    if(strcmp(L_sz_Input, "emergency", true, strlen(L_sz_Input)) == 0)
    {
        aTolls[FlintToll][E_tLocked] = 1;
        aTolls[RichmanToll][E_tLocked] = 1;
        aTolls[LVToll][E_tLocked] = 1;

        Toll_CloseToll(FlintToll);
        Toll_CloseToll(RichmanToll);
        Toll_CloseToll(LVToll);

        new L_i_Time = (GetUnixTime() + TollTimerEmergency);
        aTolls[FlintToll][E_tTimer] = L_i_Time;
        aTolls[RichmanToll][E_tTimer] = L_i_Time;
        aTolls[LVToll][E_tTimer] = L_i_Time;

        format(L_sz_MessageString, 256, "** HQ Announcement: All toll booths were LOCKED by %s! **", GetName(playerid));
        SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
    }
    else if(strcmp(L_sz_Input, "release", true, strlen(L_sz_Input)) == 0)
    {
        aTolls[FlintToll][E_tLocked] = 0;
        aTolls[RichmanToll][E_tLocked] = 0;
        aTolls[LVToll][E_tLocked] = 0;

        format(L_sz_MessageString, 256, "** HQ Announcement: All toll booths were UNLOCKED by %s! **", GetName(playerid));
        SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
    }

    else if(strcmp(L_sz_Input, "flint", true, strlen(L_sz_Input)) == 0)
    {
        if(aTolls[FlintToll][E_tLocked] == 0)
        {
            aTolls[FlintToll][E_tLocked] = 1;
            aTolls[FlintToll][E_tTimer] = (GetUnixTime() + TollTimer);
            Toll_CloseToll(FlintToll);
            format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Flint County were LOCKED by %s. **", GetName(playerid));
            SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
        }
        else
        {
            aTolls[FlintToll][E_tLocked] = 0;
            format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Flint County were UNLOCKED by %s. **", GetName(playerid));
            SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
        }
    }

    else if(strcmp(L_sz_Input, "richman", true, strlen(L_sz_Input)) == 0)
    {
        if(aTolls[RichmanToll][E_tLocked] == 0)
        {
            aTolls[RichmanToll][E_tLocked] = 1;
            aTolls[RichmanToll][E_tTimer] = (GetUnixTime() + TollTimer);
            Toll_CloseToll(RichmanToll);
            format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Richman were LOCKED by %s. **", GetName(playerid));
            SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
        }
        else
        {
            aTolls[RichmanToll][E_tLocked] = 0;
            format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Richman were UNLOCKED by %s. **", GetName(playerid));
            SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
        }
    }

    else if(strcmp(L_sz_Input, "lv", true) == 0)
    {
        if(aTolls[LVToll][E_tLocked] == 0)
        {
            aTolls[LVToll][E_tLocked] = 1;
            aTolls[LVToll][E_tTimer] = (GetUnixTime() + TollTimer);
            Toll_CloseToll(LVToll);
            format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Las Venturas were LOCKED by %s. **", GetName(playerid));
            SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
        }
        else
        {
            aTolls[LVToll][E_tLocked] = 0;
            format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Las Venturas were UNLOCKED by %s. **", GetName(playerid));
            SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
        }
    }
    return 1;
}
Test these code if you got any error tell me I only remove the faction stuff from this cmd.

if you want to use this cmd with faction stuff

Add this line
if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,-1,"You're not rcon admin.");
Reply
#5

listen, i am getting these errors:-
PHP код:
D:\michael\filterscripts\Toll.pwn(614) : error 021symbol already defined"L_sz_Input"
D:\michael\filterscripts\Toll.pwn(614) : error 033: array must be indexed (variable "-unknown-")
D:\michael\filterscripts\Toll.pwn(616) : error 028invalid subscript (not an array or too many subscripts): "L_sz_Input"
D:\michael\filterscripts\Toll.pwn(616) : error 029invalid expressionassumed zero
D
:\michael\filterscripts\Toll.pwn(616) : error 028invalid subscript (not an array or too many subscripts): "L_sz_Input"
D:\michael\filterscripts\Toll.pwn(616) : fatal error 107too many error messages on one line 
and these are the lines of error:-
PHP код:
Line 614:- L_sz_Input strtok(cmdtextidx);
Line 616:- if(IsNull(L_sz_Input)) 
kindly, tell me how to fix it?
Reply
#6

Delete
Reply
#7

Код:
public ycmd_toll(playerid, cmdtext[])
{
    #if TollFS == 0
        if(cmdtext[0] == 1) cmdtext[0] = 0;

        if(!gPlayerLogged[playerid])
        {
            SendClientMessage(playerid, COLOR_RED, "You are not logged in.");
            return 1;
        }
    #endif
    if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,-1,"You're not rcon admin.");
    new idx,
        L_sz_Input[256],
        L_sz_MessageString[256];
    	L_sz_Input = strtok(cmdtext, idx);

    if(IsNull(L_sz_Input))
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Toll barrier command central for Los Santos");
        SendClientMessage(playerid, COLOR_GRAD2, "emergency/release - (Un)Locks all the barriers.");
        SendClientMessage(playerid, COLOR_GRAD2, "flint - (Un)locks flint tolls.");
        SendClientMessage(playerid, COLOR_GRAD2, "richman - (Un)locks Richman tunnel tolls.");
        SendClientMessage(playerid, COLOR_GRAD2, "lv - (Un)locks the Las Venturas Highway tolls.");
        return 1;
    }

    if(strcmp(L_sz_Input, "emergency", true, strlen(L_sz_Input)) == 0)
    {
        aTolls[FlintToll][E_tLocked] = 1;
        aTolls[RichmanToll][E_tLocked] = 1;
        aTolls[LVToll][E_tLocked] = 1;

        Toll_CloseToll(FlintToll);
        Toll_CloseToll(RichmanToll);
        Toll_CloseToll(LVToll);

        new L_i_Time = (GetUnixTime() + TollTimerEmergency);
        aTolls[FlintToll][E_tTimer] = L_i_Time;
        aTolls[RichmanToll][E_tTimer] = L_i_Time;
        aTolls[LVToll][E_tTimer] = L_i_Time;

        format(L_sz_MessageString, 256, "** HQ Announcement: All toll booths were LOCKED by %s! **", GetName(playerid));
        SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
    }
    else if(strcmp(L_sz_Input, "release", true, strlen(L_sz_Input)) == 0)
    {
        aTolls[FlintToll][E_tLocked] = 0;
        aTolls[RichmanToll][E_tLocked] = 0;
        aTolls[LVToll][E_tLocked] = 0;

        format(L_sz_MessageString, 256, "** HQ Announcement: All toll booths were UNLOCKED by %s! **", GetName(playerid));
        SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
    }

    else if(strcmp(L_sz_Input, "flint", true, strlen(L_sz_Input)) == 0)
    {
        if(aTolls[FlintToll][E_tLocked] == 0)
        {
            aTolls[FlintToll][E_tLocked] = 1;
            aTolls[FlintToll][E_tTimer] = (GetUnixTime() + TollTimer);
            Toll_CloseToll(FlintToll);
            format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Flint County were LOCKED by %s. **", GetName(playerid));
            SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
        }
        else
        {
            aTolls[FlintToll][E_tLocked] = 0;
            format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Flint County were UNLOCKED by %s. **", GetName(playerid));
            SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
        }
    }

    else if(strcmp(L_sz_Input, "richman", true, strlen(L_sz_Input)) == 0)
    {
        if(aTolls[RichmanToll][E_tLocked] == 0)
        {
            aTolls[RichmanToll][E_tLocked] = 1;
            aTolls[RichmanToll][E_tTimer] = (GetUnixTime() + TollTimer);
            Toll_CloseToll(RichmanToll);
            format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Richman were LOCKED by %s. **", GetName(playerid));
            SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
        }
        else
        {
            aTolls[RichmanToll][E_tLocked] = 0;
            format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Richman were UNLOCKED by %s. **", GetName(playerid));
            SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
        }
    }

    else if(strcmp(L_sz_Input, "lv", true) == 0)
    {
        if(aTolls[LVToll][E_tLocked] == 0)
        {
            aTolls[LVToll][E_tLocked] = 1;
            aTolls[LVToll][E_tTimer] = (GetUnixTime() + TollTimer);
            Toll_CloseToll(LVToll);
            format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Las Venturas were LOCKED by %s. **", GetName(playerid));
            SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
        }
        else
        {
            aTolls[LVToll][E_tLocked] = 0;
            format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Las Venturas were UNLOCKED by %s. **", GetName(playerid));
            SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
        }
    }
    return 1;
}
Код:
GetName(playerid)
{
	new JName[MAX_PLAYER_NAME];
	GetPlayerName(playerid,JName,MAX_PLAYER_NAME);
	return JName;
}
test now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)