SA-MP Forums Archive
i want to use this command only for admin.... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: i want to use this command only for admin.... (/showthread.php?tid=224138)



i want to use this command only for admin.... - deviljingoku - 11.02.2011

please help me friends.....i have this auto repair function in my gamemode.....i want auto reair vehicle for only admin..
or if i want it only auto repair work in race stunt area only its lv.....if auto repair work only in lv....??



SetTimer("AutoR", 1000, 1);
return 1;
}

public OnFilterScriptExit()
{
return 1;
}

public AutoR() {
for(new playerid=0; playerid<MAX_PLAYERS; playerid++) {
if(IsPlayerConnected(playerid)) {
new Float:health, cid;
if (IsPlayerInAnyVehicle(playerid)) {
cid = GetPlayerVehicleID(playerid);
GetVehicleHealth(cid, health);
if (health < 300) {
SetVehicleHealth(cid,1000);
GameTextForPlayer(playerid, "Vehicul reparat!",2000,5);
}
}
}
}
return 1;
}


Re: i want to use this command only for admin.... - Stigg - 11.02.2011

Try.

if(!IsPlayerAdmin(playerid)) return 1;

Peace...


Re: i want to use this command only for admin.... - Antonio [G-RP] - 11.02.2011

pawn Код:
public AutoR()
{
    for(new playerid=0; playerid<MAX_PLAYERS; playerid++) {
        if(IsPlayerConnected(playerid)) {
            new Float:health, cid;
            if (IsPlayerInAnyVehicle(playerid)) {
                if(IsPlayerAdmin(playerid)) { // RCON admin only
                    if(IsPlayerInRangeOfPoint(playerid, 15, Float:x, Float:y, Float:z)) { // 15 = The range of the points. Fill in your x, y, and z co-ords.
                        cid = GetPlayerVehicleID(playerid);
                        GetVehicleHealth(cid, health);
                        if (health < 300) {
                            SetVehicleHealth(cid,1000);
                            GameTextForPlayer(playerid, "Vehicul reparat!",2000,5);
                        }
                    }
                }
            }
        }
    }
    return 1;
}



Re: i want to use this command only for admin.... - deviljingoku - 11.02.2011

Quote:

F:\Harrysingh softs\samp03csvr_win32\gamemodes\mygm.pwn(30) : error 017: undefined symbol "isPlayerAdmin"
F:\Harrysingh softs\samp03csvr_win32\gamemodes\mygm.pwn(31) : error 017: undefined symbol "x"
F:\Harrysingh softs\samp03csvr_win32\gamemodes\mygm.pwn(33) : warning 217: loose indentation
F:\Harrysingh softs\samp03csvr_win32\gamemodes\mygm.pwn(34) : warning 217: loose indentation
F:\Harrysingh softs\samp03csvr_win32\gamemodes\mygm.pwn(36) : warning 217: loose indentation
F:\Harrysingh softs\samp03csvr_win32\gamemodes\mygm.pwn(41) : warning 217: loose indentation
F:\Harrysingh softs\samp03csvr_win32\gamemodes\mygm.pwn(43) : error 030: compound statement not closed at the end of file (started at line 27)

Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


3 Errors.


Re: i want to use this command only for admin.... - HyperZ - 11.02.2011

pawn Код:
public AutoR()
{
    for(new playerid=0; playerid<MAX_PLAYERS; playerid++)
    {
        if(IsPlayerConnected(playerid))
        {
            new Float:health, cid;
            if (IsPlayerInAnyVehicle(playerid))
            {
                if(IsPlayerAdmin(playerid)) return 0;
                cid = GetPlayerVehicleID(playerid);
                GetVehicleHealth(cid, health);
                if (health < 300)
                {
                SetVehicleHealth(cid,1000);
                GameTextForPlayer(playerid, "Vehicul reparat!",2000,5);
                }
            }
        }
    }
    return 1;
}



Re: i want to use this command only for admin.... - deviljingoku - 11.02.2011

thanx for help me....now i dont want it only for admin....can you help me...
can you tell me how i do it...? only auto repair will work in los santos or in sf(san fiero) only in one area...?


Re: i want to use this command only for admin.... - wups - 11.02.2011

Quote:
Originally Posted by Clive
Посмотреть сообщение
pawn Код:
public AutoR()
{
    for(new playerid=0; playerid<MAX_PLAYERS; playerid++)
    {
        if(IsPlayerConnected(playerid))
        {
            new Float:health, cid;
            if (IsPlayerInAnyVehicle(playerid))
            {
                if(IsPlayerAdmin(playerid)) return 0;
                cid = GetPlayerVehicleID(playerid);
                GetVehicleHealth(cid, health);
                if (health < 300)
                {
                SetVehicleHealth(cid,1000);
                GameTextForPlayer(playerid, "Vehicul reparat!",2000,5);
                }
            }
        }
    }
    return 1;
}
Actualy
pawn Код:
if(!IsPlayerAdmin(playerid)) continue;
Quote:
Originally Posted by deviljingoku
Посмотреть сообщение
.....i want auto reair vehicle for only admin..
}
Quote:
Originally Posted by deviljingoku
Посмотреть сообщение
....now i dont want it only for admin....



Re: i want to use this command only for admin.... - deviljingoku - 11.02.2011

Quote:
Originally Posted by deviljingoku
Посмотреть сообщение
thanx for help me....now i dont want it only for admin....can you help me...
can you tell me how i do it...? only auto repair will work in los santos or in sf(san fiero) only in one area...?
i want it only in lv area its stunting area so there i want auto repair....??


Re: i want to use this command only for admin.... - Mean - 11.02.2011

Quote:
Originally Posted by wups
Посмотреть сообщение
Actualy
pawn Код:
if(!IsPlayerAdmin(playerid)) continue;




Actually it works that way too!
Also, for the area, you can search for IsPlayerInArea in here, or just use IsPlayerInRangeOfPoint
pawn Код:
if ( IsPlayerInRangeOfPoint( playerid, Float:range, Float:x, Float:y, Float:z ) )
{
    SendClientMessage( playerid, 0xAAAAAA, "YAY! You are in range!" );
}
else
{
    SendClientMessage( playerid, 0xAAAAAA, "You are not in range!" );
}
Example usage^^


Re: i want to use this command only for admin.... - wups - 11.02.2011

Quote:
Originally Posted by Clive
Посмотреть сообщение
pawn Код:
public AutoR()
{
    for(new playerid=0; playerid<MAX_PLAYERS; playerid++)
    {
        if(IsPlayerConnected(playerid))
        {
            new Float:health, cid;
            if (IsPlayerInAnyVehicle(playerid))
            {
                if(IsPlayerAdmin(playerid)) return 0;
                cid = GetPlayerVehicleID(playerid);
                GetVehicleHealth(cid, health);
                if (health < 300)
                {
                SetVehicleHealth(cid,1000);
                GameTextForPlayer(playerid, "Vehicul reparat!",2000,5);
                }
            }
        }
    }
    return 1;
}
if(IsPlayerAdmin(playerid)) return 0;
This stops the function from executing. For example: if player 0 is not admin, then it will not check for other players.
Quote:
Originally Posted by [GF]Sasino97
Посмотреть сообщение
What does the
pawn Код:
continue;
function?
It continues the loop.
For example: Player 0 is not admin, then i write continue; and it continues to player 1 and so on.
Quote:
Originally Posted by Mean
Посмотреть сообщение
Actually it works that way too!
I posted why it doesn't work the way Clive posted.