ZCMD Problem
#1

PHP код:
CMD:server(playerid,params[])
{
if(
GetPVarInt(playerid,"AdminLvl") < 20) return 0;
if(
isnull(params)) 
return 
SendClientMessage(playerid,COLOR_WHITE,"Usage: /Server <Name/Gmx>");
if(!
strcmp(params,"Name",true))
{
new 
string[128];
if(
isnull(params)) return SendClientMessage(playerid,COLOR_RED,"Usage: /Server <Name> <ServerName>");
format(string,128,"The server name was changed to %s",params);
SendClientMessage(playerid,COLOR_RED,string);
return 
1;
}
return 
1;

Why this not write the name of the server?
Reply
#2

Well the code doesn't make a lot of sense, first of all you check if the params variable is null, then after you've confirmed it is not null, you check if it is null again!

Either way, it's not changing the name of the server because you're not using any function which changes the name of the server in this snippet of code. You need a function like SendRconCommand.
Reply
#3

I have a problem..


I tried to do that:
PHP код:
CMD:server(playerid,params[])
{
if(
GetPVarInt(playerid,"AdminLvl") < 20) return 0;
if(
isnull(params)) 
return 
SendClientMessage(playerid,COLOR_WHITE,"Usage: /Server <Name/Gmx>");
if(!
strcmp(params,"Name",true))
{
new 
string[128];
if(
isnull(params)) return SendClientMessage(playerid,COLOR_RED,"Usage: /Server <Name> <ServerName>");
format(string,128,"The server name was changed to %s",params);
SendClientMessage(playerid,COLOR_RED,string);
format(string,128,"hostname %s",params);
SendRconCommand(string);
return 
1;
}
return 
1;

Problem is that it changes the name to "Name"
Reply
#4

Try this one :')
Btw: https://sampforum.blast.hk/showthread.php?tid=268499
pawn Код:
CMD:server(playerid, params[])
{
    if(IsPlayerAdmin(playerid)) return 0;
    if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /server <new name OR just gmx>");
    if(!strcmp(params, "gmx")) return SendClientMessageToAll(COLOR_WHITE, "Server restart!"), SendRconCommand("gmx");
    else
    {
        new str[128];
        format(str, 128, "The server name's been changed to: %s", params[0]); //Try params[0] instead of params?
        SendClientMessageToAll(COLOR_RED, str);
        format(str, 128, "hostname %s", params[0]);
        SendRconCommand(str);
        return 1;
    }
}
Forgot it, I wanted to test it (you must test a code before posting it), but I must reinstall GTA San Andreas: It's not working. Sorry, I couldn't test it yet. However, if you do:

/server gmx
It will restart the server (Atleast, it should do that )

/server {any_other_name}
It will change the server's name to {any_other_name} and send to everyone a message.

/server Kwarde
It will change the server's name to Kwarde
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)