SA-MP Forums Archive
If help - 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)
+--- Thread: If help (/showthread.php?tid=293654)



If help - manchestera - 29.10.2011

Ok how can i change this so that it would accept a list of players names
Код:
if(IsPlayerAdmin(playerid))
Manythanks.


Re: If help - [MG]Dimi - 29.10.2011

Can you explain a bit more?

P.S. Come on MSN once you are free


Re: If help - manchestera - 29.10.2011

See where it say if admin i want to have a list of players names that can use the cmd where i can add names to the list and they can use the cmd.

So say if Group then i have a list like

new group

group
{
name1
name2
name3
}


Re: If help - manchestera - 29.10.2011

This is what i have tried but i got some errors and not even sure if it will work.

Код:
new group//line29 to line35
public Group
}
[SW]BlackWidow
{
return 0;
}//line35
Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)//43 line
{
	
	if GetPlayerName(Group)
	{
	ShowPlayerDialog(playerid,9137,DIALOG_STYLE_LIST,"Control Panel For{EBF700}Admin","{FF0000}Kick\n{FF0000}Ban\n{FF0000}Explode\n{FF0000}Burn\n{FF0000}Slap\n{FF0000}Jail\n{FF0000}UnJail\n{FF0000}Disarm\n{FF0000}Arm\n{FF0000}Ignore\n{FF0000}Freeze\n{FF0000}Unfreeze\n{FF0000}Mute\n{FF0000}Unmute\n{FF0000}Bring\n{FF0000}Goto\n{FF0000}Heal\n{FF0000}GiveArmour\n{FF0000}Kill\n{FF0000}Spawn\n{FF0000}Spectate\n{FF0000}Spectate Off\n{FF0000}GameText","Action","Cancel");
	pClicked[playerid] = clickedplayerid;
	return 1;
	}
	return 1;
}//52 line
Код:
C:\Users\GTA ONLY\Desktop\smartass\smartass.pwn(30) : error 001: expected token: ";", but found "public"
C:\Users\GTA ONLY\Desktop\smartass\smartass.pwn(34) : error 010: invalid function or declaration
C:\Users\GTA ONLY\Desktop\smartass\smartass.pwn(45) : warning 202: number of arguments does not match definition
C:\Users\GTA ONLY\Desktop\smartass\smartass.pwn(45) : warning 202: number of arguments does not match definition
C:\Users\GTA ONLY\Desktop\smartass\smartass.pwn(46) : error 001: expected token: "*then", but found "{"
C:\Users\GTA ONLY\Desktop\smartass\smartass.pwn(331) : warning 203: symbol is never used: "group"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.



Re: If help - blewert - 29.10.2011

Kind of not sure what you want, but I assume it's checking whether a string is in a fixed size character array? Fixed your code:

pawn Код:
//Fixed size array for names.
//..
//ARRAY[ ENTRIES ] [ ENTRY SIZE ]

new group[ ] [ MAX_PLAYER_NAME ] =
{
    "[SW]BlackWidow",
    "anothername"   ,
    "yetanothername"
};

stock IsPlayerInGroup( const _:playerid )
{
    //Function to check whether the playerid's name is in the newly created array.
    if( IsPlayerConnected( playerid ) )
    {
        //If they're connected.
        new szName[ MAX_PLAYER_NAME ],
               bool:rVal;
       
        //Get their name, store it in szName
        GetPlayerName( playerid, szName, sizeof szName );
       
        for( new i; i < sizeof group; i++ )
        {
            //Run through each entry of the group
            if( !strcmp( szName, group[ i ], true ) )
            {
                //If their name is in it, then exit the loop and return true.
                rVal = ( true );
                break;
            }
            //If their name is not in the group, change rVal to false.
            rVal = false;
        }
        //Return rVal.
        return rVal;
    }
    //Return false (they're not connected)
    return ( false );
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{

    if( IsPlayerInGroup( playerid ) )
    {
        //If they're in the group, show the dialog.
        ShowPlayerDialog(playerid,9137,DIALOG_STYLE_LIST,"Control Panel For{EBF700}Admin","{FF0000}Kick\n{FF0000}Ban\n{FF0000}Explode\n{FF0000}Burn\n{FF0000}Slap\n{FF0000}Jail\n{FF0000}UnJail\n{FF0000}Disarm\n{FF0000}Arm\n{FF0000}Ignore\n{FF0000}Freeze\n{FF0000}Unfreeze\n{FF0000}Mute\n{FF0000}Unmute\n{FF0000}Bring\n{FF0000}Goto\n{FF0000}Heal\n{FF0000}GiveArmour\n{FF0000}Kill\n{FF0000}Spawn\n{FF0000}Spectate\n{FF0000}Spectate Off\n{FF0000}GameText","Action","Cancel");
        pClicked[playerid] = clickedplayerid;
        return 1;
    }
    return 1;
}
Compiled and tested on server, works fine.


Re: If help - manchestera - 29.10.2011

You beast lol thank man.