Stock/Callback how do i make this possible?
#1

I would to make a stock or callback that

PHP код:
If(PlayerInfo[playerid][pAdmin] == 1)
{
       
format(string,sizeof(string), "Junior Admin");

So when i make /adminchat cmd i don't need to make multiple if / else statements.

Is this possible, Thanks!
Reply
#2

There is no such thing as "a stock". Their is something called a stock function but what you're looking for is a normal function. A stock function in its most pure sense is a function that can be copied into any script without any alterations. That concludes the speech for misuse of the stock keyword.

Anyway, what I would do is create an array of titles and then simply select the right value by using the rank as the index.
PHP код:
GetLevelTitle(level)
{
    static const 
gAdminTitles[][] = {
        
"None"// 0
        
"Junior Admin"// 1
        
"Admin"// 2
        
"Senior Admin" // 3
    
};
    return 
gAdminTitles[level];

Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
There is no such thing as "a stock". Their is something called a stock function but what you're looking for is a normal function. A stock function in its most pure sense is a function that can be copied into any script without any alterations. That concludes the speech for misuse of the stock keyword.

Anyway, what I would do is create an array of titles and then simply select the right value by using the rank as the index.
PHP код:
GetLevelTitle(level)
{
    static const 
gAdminTitles[][] = {
        
"None"// 0
        
"Junior Admin"// 1
        
"Admin"// 2
        
"Senior Admin" // 3
    
};
    return 
gAdminTitles[level];

Thanks bro, But i got this error
Код:
C:\Users\user\Desktop\lewl\gamemodes\lewl.pwn(2345) : error 010: invalid function or declaration
C:\Users\user\Desktop\lewl\gamemodes\lewl.pwn(2345 -- 2356) : error 010: invalid function or declaration
PHP код:
GetLevelTitle(level)
{
    static const 
gAdminTitles[][] = {
        
"None"// 0
        
"Black-Listed"// 1
        
"Junior Admin"// 2
        
"General Admin" // 3
        
"Senior Admin"
        "Head Admin"
        "Server Manager"
    
};
    return 
gAdminTitles[level];

Reply
#4

PHP код:
GetLevelTitle(level

    static const 
gAdminTitles[][] = { 
        
"None"// 0 
        
"Black-Listed"// 1 
        
"Junior Admin"// 2 
        
"General Admin",// 3 
        
"Senior Admin",
        
"Head Admin",
        
"Server Manager" 
    
}; 
    return 
gAdminTitles[level]; 

Reply
#5

Quote:
Originally Posted by Micko123
Посмотреть сообщение
PHP код:
GetLevelTitle(level

    static const 
gAdminTitles[][] = { 
        
"None"// 0 
        
"Black-Listed"// 1 
        
"Junior Admin"// 2 
        
"General Admin",// 3 
        
"Senior Admin",
        
"Head Admin",
        
"Server Manager" 
    
}; 
    return 
gAdminTitles[level]; 

Thanks now i got this error when i tried to call the function on my /a cmd

C:\Users\user\Desktop\lewl Roleplay\gamemodes\lewl.pwn(36082) : error 017: undefined symbol "level"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.

Line:
Quote:

format(szMessage, sizeof(szMessage), "* %s %s: %s", GetLevelTitle(level), GetPlayerNameEx(playerid), params);

Full Code
PHP код:
CMD:admin(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >= 1) {
        if(!
isnull(params))
        {
            new 
szMessage[128];
            
format(szMessagesizeof(szMessage), "* %s %s: %s"GetLevelTitle(level), GetPlayerNameEx(playerid), params);
        }
        else 
SendClientMessage(playeridCOLOR_WHITE"USAGE: (/a)dmin [admin chat]");
    }
    return 
1;

Reply
#6

try by doing this
PHP код:
CMD:admin(playeridparams[]) 

    if(
PlayerInfo[playerid][pAdmin] >= 1) { 
        if(!
isnull(params)) 
        { 
            new 
szMessage[128], level[50];
            
format(szMessagesizeof(szMessage), "* %s %s: %s"GetLevelTitle(level), GetPlayerNameEx(playerid), params); 
        } 
        else 
SendClientMessage(playeridCOLOR_WHITE"USAGE: (/a)dmin [admin chat]"); 
    } 
    return 
1

Reply
#7

Quote:
Originally Posted by Micko123
Посмотреть сообщение
try by doing this
PHP код:
CMD:admin(playeridparams[]) 

    if(
PlayerInfo[playerid][pAdmin] >= 1) { 
        if(!
isnull(params)) 
        { 
            new 
szMessage[128], level[50];
            
format(szMessagesizeof(szMessage), "* %s %s: %s"GetLevelTitle(level), GetPlayerNameEx(playerid), params); 
        } 
        else 
SendClientMessage(playeridCOLOR_WHITE"USAGE: (/a)dmin [admin chat]"); 
    } 
    return 
1

PHP код:
C:\Users\user\Desktop\Ssa Roleplay\gamemodes\asm.pwn(36083) : error 035argument type mismatch (argument 1
Quote:

format(szMessage, sizeof(szMessage), "* %s %s: %s", GetLevelTitle(level), GetPlayerNameEx(playerid), params);

Reply
#8

Try this
Код:
format(szMessage, sizeof(szMessage), "* %s %s: %s", GetLevelTitle(level), GetPlayerNameEx(playerid));
Reply
#9

Do you even pawn brah? From what I see you either have 0 intention of learning, or are a newbie that is trying to learn in the worst and hardest way.
Copy pasting things all over a text editor won't make a gamemode, read some tutorials, learn a bit about writing codes then start this.

And seriously how people started calling functions stocks? why can't we see same people calling variables "news"?
Reply
#10

Quote:
Originally Posted by Micko123
Посмотреть сообщение
Try this
Код:
format(szMessage, sizeof(szMessage), "* %s %s: %s", GetLevelTitle(level), GetPlayerNameEx(playerid));
Does'nt help i still get the error
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)