Add Command
#1

Hello guys, I have come to such a command here , but she does not work , somehow I get by typing / add_police <nick > lent Player to police dini.

PHP код:
CMD:add_police(playeridparams[])
    {
        new 
Gracz [64];
        new 
PlayerName[MAX_PLAYER_NAME];
        
GetPlayerName(playerid,PlayerName,sizeof(PlayerName));
        
format(Gracz,sizeof(Gracz), KONTA ,PlayerName);
        if(
strcmp(PlayerName"Chef_Name"true) == 0)
        {
            if(
isnull(params) || strlen(params) &gtMAX_PLAYER_NAME
            return 
SendClientMessage(playerid, -1"/add_police [nick]"); 
            
dini_IntSet(Gracz,"Police"1);
        }
        return 
1;
    } 
Reply
#2

totally don't understand what are you trying to say. what you get when typing add_police (andremove that '_' from command)
Reply
#3

I would like to create a command that will add player to fractions by nickname . I use Include dini what you see .
Reply
#4

I think I get it. When a player type /add_police, the player is added to the faction 'Police' ?
Firstly, You need to show your parameters with the enum like :
PHP код:
enum pInfo
{
    
pMDP,
    
pAdminlvl,
    
pCash,
    
pScore,
    
pLog,
    ...

I will try to explain how does parameters work.
You have enmuerated player info by a var (called pInfo for me). To call those var', you need an another var' which is like that :
PHP код:
new PlayerInfo[MAX_PLAYERS][pInfo
For exemple, if I want call the seconde variable (pAdminlvl) I write : PlayerInfo[playerid][pAdminlvl]. You get it ?
Now:
PHP код:
dini_IntSet(Gracz,"Police"1); 
This thing is only when you have already open the file (thanks to : INI:NameOfFile = INI_Open(PathOfTheFile))
To change a variable of a player like an admin level, you need to do like that :
Exemple set admin lvl 5 (owner) :
PHP код:
CMD:admin(playeridparams[])
{
    
PlayerInfo[playerid][pAdminlvl] = 5// Changing the variable pAdminlvl to 5. (Changing admin level of the player to 5)
    
SendClientMessage(playerid, -1"You are now the owner of the server!");
    return 
1;

By the way this is juste an example, you need to change PlayerInfo[playerid][pAdminlvl] by your own variable.
My english is very bad as you can see. If you didn't understand something say it.
If you want some help for your cmd, show us : enumerate parameters and var' which get enumerated para'.
Reply
#5

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
I think I get it. When a player type /add_police, the player is added to the faction 'Police' ?
Firstly, You need to show your parameters with the enum like :
PHP код:
enum pInfo
{
    
pMDP,
    
pAdminlvl,
    
pCash,
    
pScore,
    
pLog,
    ...

I will try to explain how does parameters work.
You have enmuerated player info by a var (called pInfo for me). To call those var', you need an another var' which is like that :
PHP код:
new PlayerInfo[MAX_PLAYERS][pInfo
For exemple, if I want call the seconde variable (pAdminlvl) I write : PlayerInfo[playerid][pAdminlvl]. You get it ?
Now:
PHP код:
dini_IntSet(Gracz,"Police"1); 
This thing is only when you have already open the file (thanks to : INI:NameOfFile = INI_Open(PathOfTheFile))
To change a variable of a player like an admin level, you need to do like that :
Exemple set admin lvl 5 (owner) :
PHP код:
CMD:admin(playeridparams[])
{
    
PlayerInfo[playerid][pAdminlvl] = 5// Changing the variable pAdminlvl to 5. (Changing admin level of the player to 5)
    
SendClientMessage(playerid, -1"You are now the owner of the server!");
    return 
1;

By the way this is juste an example, you need to change PlayerInfo[playerid][pAdminlvl] by your own variable.
My english is very bad as you can see. If you didn't understand something say it.
If you want some help for your cmd, show us : enumerate parameters and var' which get enumerated para'.
This has nothing to do with his code and his problem is not here. He already said that he's using dini.


Try using sscanf instead. IsNumeric is included in it.
Код:
CMD:add_police(playerid, params[]) 
{ 
	new Gracz[64], id, PlayerName[MAX_PLAYER_NAME]; 
	if (sscanf(params, "u", id)) SendClientMessage(playerid, -1, "/add_police [nick]");  
	{
		if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, -1, "Invalid playerid");  
		GetPlayerName(id, PlayerName, sizeof(PlayerName)); 
		format(Gracz, sizeof(Gracz), KONTA, PlayerName); 
		dini_IntSet(Gracz,"Police", 1);
	} 
	return 1; 
}
This command should work.
Reply
#6

Commands have genders now?

Type in their ID instead of their nickname.
Reply
#7

Quote:
Originally Posted by Luis-
Посмотреть сообщение
Commands have genders now?

Type in their ID instead of their nickname.
He's using GetPlayerName to find the path for the player-file.

Код:
GetPlayerName(id, PlayerName, sizeof(PlayerName)); 
format(Gracz, sizeof(Gracz), KONTA, PlayerName); 
dini_IntSet(Gracz, "Police", 1);
dini_IntSet parameters are filename[], key[], value.
That's why need to use format and GetPlayerName. "KONTA" is probably the path to the player-file.

EDIT: Using sscanf it finds the path to player-file by typing only the ID of the player (not the full name).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)