Add Name To The Name Server (?)
#1

How can I add name to my name server? I want to add to the end (HeadShot) or (Race), how can I do it with command without to write the full name?


Thanks
Reply
#2

Try this;
pawn Код:
#define HOSTNAME SA-MP Server
pawn Код:
public OnGameModeInit()
{
    SendRconCommand( "hostname "#HOSTNAME"" );

    return 1;
}
pawn Код:
public OnPlayerCommandText( playerid, cmdtext[] )
{
    new
        cmd[ 128 ],
        tmp[ 128 ],
        idx
    ;

    cmd = strtok( cmdtext, idx );

    if( !strcmp( cmd, "/addtohostname", true ) )
    {
        new
            hostname[ 128 ]
        ;
   
        tmp = strrest( cmdtext, idx );
       
        if( !strlen( tmp ) )
            return SendClientMessage( playerid, -1, "USAGE: /addtohostname [text]" );
           
        format( hostname, 128, "hostname "#HOSTNAME" %s", tmp );
        SendRconCommand( hostname );
   
        return 1;
    }

    return 0;
}
pawn Код:
stock strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
pawn Код:
stock strrest(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }
    new offset = index;
    new result[128];
    while ((index < length) && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Reply
#3

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)