22.02.2012, 11:05
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
Thanks
#define HOSTNAME SA-MP Server
public OnGameModeInit()
{
SendRconCommand( "hostname "#HOSTNAME"" );
return 1;
}
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;
}
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;
}
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;
}