Add Name To The Name Server (?) - 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: Add Name To The Name Server (?) (
/showthread.php?tid=320248)
Add Name To The Name Server (?) -
tal_peretz - 22.02.2012
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
Re: Add Name To The Name Server (?) -
Toreno - 22.02.2012
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;
}
Re: Add Name To The Name Server (?) -
tal_peretz - 22.02.2012
Thanks