[HELP] You can or?
#1

Well, I am getting always the message "Server: Unknown Command" after typing some commands of mine after login. There does nothing happen. What's wrong?

Check:
PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    new 
stringx[128];
    
format(stringx,sizeof(stringx),"There is no %s Command.",cmdtext);
    
//AFK
    
if(strcmp(cmdtext"/afk"true) == 0)
    {
        new 
pName[MAX_PLAYER_NAME]; // Saying pName is the Players Name!
        
new string[128]; // Creating the string.
        
GetPlayerName(playerid,pName,MAX_PLAYER_NAME); // tells the pName to get the players name!
        
format(stringsizeof(string), "--> %s is now AFK",pName); // This is what will send to everyone!
        
SendClientMessageToAll(LIGHTBROWNstring); // This is what makes the "string" send in the "COLOR_BLUE"!
        
GameTextForPlayer(playerid,"~w~You ~b~are ~r~AFK ~w~now!",3000,5);
        
TogglePlayerControllable(playerid0); // Makes it so the player cannot move.
        
SetPlayerHealth(playerid999999.999); // Sets the players health so he is invincible! So noone can kill him.
        
return 1;
    }
    
//BACK
    
if(strcmp(cmdtext"/back"true) == 0)
    {
        new 
pName[MAX_PLAYER_NAME]; // Saying pName is the Players Name!
        
new string[128]; // Creating the string.
        
GetPlayerName(playerid,pName,MAX_PLAYER_NAME); // tells the pName to get the players name!
        
format(stringsizeof(string), "--> %s is now BACK",pName); // This is what will send to everyone!
        
SendClientMessageToAll(LIGHTBROWNstring); // This is what makes the "string" send in the "COLOR_BLUE"!
        
GameTextForPlayer(playerid,"~w~You ~b~are ~r~BACK ~w~now!",3000,5);
        
TogglePlayerControllable(playerid1); // Makes it so the player can move.
        
SetPlayerHealth(playerid100); // Sets the players health back to normal. He is now killable.
        
return 1;
    }
    
//Turn lights on
    
if(strcmp(cmdtext"/lights on",true)==0)
    {
        new 
vid GetPlayerVehicleID(playerid);
        if(
vid != INVALID_VEHICLE_ID)
        {
            
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            
SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
        }
        return 
1;
    }
    
//Turn off lights
    
if(strcmp(cmdtext"/lights off",true)==0)
    {
        new 
vid GetPlayerVehicleID(playerid);
        if(
vid != INVALID_VEHICLE_ID)
        {
            
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            
SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
        }
        return 
1;
    }
    
//StartEngine
    
if(strcmp(cmdtext"/start engine",true)==0)
    {
        new 
vid GetPlayerVehicleID(playerid);
        if(
vid != INVALID_VEHICLE_ID)
        {
            
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            
SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
        }
        return 
1;
    }
    
//Turn off Engine
    
if(strcmp(cmdtext"/stop engine",true)==0)
    {
        new 
vid GetPlayerVehicleID(playerid);
        if(
vid != INVALID_VEHICLE_ID)
        {
            
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            
SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
        }
        return 
1;
    }
    if(
strcmp(cmdtext"/buy phone",true)==0)
    {
        if(
IsPlayerInRangeOfPoint(playerid,1,-2235.3987,130.1578,1035.4141))
        {
        
        }
        else
           {
            
SendClientMessage(playerid0xAF2800FF,"You have to stand in the pickup");
            
        }
        return 
1;
    }
    if(
strcmp(cmdtext"/stats"true) == 0// unser Command, kann natьrlich auch anders angeordnet sein jenachdem wie er bei euch im Script definiert ist!
    
{
        
MyDialogStatsSystem(playerid); // Цffnet unsere Stats :5
        
return 1;
    }
    if(
strcmp(cmdtext,"/jobs",true)==0)
    {
        if(
IsPlayerInRangeOfPoint(playerid,1,2308.8784,-2.1824,26.7422))
        {
            
SendClientMessage(playerid,DARKGREEN,"Will come soon..");
        }
        else
        {
            
SendClientMessage(playerid0xAF2800FF,"You have to stand in the pickup");
        }
        return 
1;
    }
    if(
strcmp(cmdtext,"/score5",true)==0)
    {
        
SetPlayerScore(playerid,5); //Um level zu setzen
        
return 1;
    }
    if(
strcmp(cmdtext,"/dslsopen",true)==0)
    {
        
MoveObject(dslsc2846.50195312,-1974.86914062,3.602674482); //object(elecfence_bar) (7)
        
SendClientMessage(playeridWHITE,"You've {FF0000}opened {FAFAFA}the gate!");
        return 
1;
    }
    if(
strcmp(cmdtext,"/dslsclose",true)==0)
    {
        
MoveObject(dslsc2846.50195312,-1974.86962891,10.102674482);
        
SendClientMessage(playeridWHITE,"You've {FF0000}closed {FAFAFA}the gate!");
        return 
1;
    }
    if(
strcmp(cmdtext,"/test",true)==0)
    {
        
SendClientMessage(playerid,ORANGE,"This command will give you {FF0000}$500 & -60HP");
        
a_GivePlayerMoney(playerid500);
        
SetPlayerHealth(playerid10.0);
        return 
1;
    }
    if(
strcmp(cmdtext,"/help",true)==0)
    {
        
SendClientMessage(playerid,ORANGE,"|________HELP________|");
        
SendClientMessage(playerid,ORANGE,"** MAIN ** {FF0000}/about /score5 /afk /back");
        
SendClientMessage(playerid,ORANGE,"** FUN ** {FF0000}/test /dslsclose /dslsopen");
        
SendClientMessage(playerid,ORANGE,"** CAR ** {FF0000}/start engine /stop engine /lights on /lights off");
        
SendClientMessage(playerid,ORANGE,"|____________________|");
        return 
1;
    }
    if(
strcmp(cmdtext,"/about",true)==0)
    {
        
SendClientMessage(playerid,ORANGE,"|________ABOUT________|");
        
SendClientMessage(playerid,WHITE,"Crossfire Roleplay Server 0.3c");
        
SendClientMessage(playerid,WHITE,"Script: CF-RP v0.1 by ScoOf");
        
SendClientMessage(playerid,WHITE,"Server location: Germany");
        
SendClientMessage(playerid,WHITE,"mIRC: #crossfire");
        
SendClientMessage(playerid,ORANGE,"|_____________________|");
        return 
1;
    }
    return 
SendClientMessage(playerid,0x9362A3FF,stringx);

Reply
#2

Spaces don't work with commands?
Reply
#3

Are you sure? It worked before. Now I dont know why it doesnt work anymore.
Reply
#4

So half of the commands work and the other half don't?
Reply
#5

No. No one works. I become always a message: " Server Unknown Command." + the command does nothing. for example the help command doesnt show me the help commands, there just comes the message server unknown command :<
Reply
#6

So, i fixed your code


pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    //AFK
    if(strcmp(cmdtext, "/afk", true) == 0)
    {
        new pName[MAX_PLAYER_NAME]; // Saying pName is the Players Name!
        new string[128]; // Creating the string.
        GetPlayerName(playerid,pName,MAX_PLAYER_NAME); // tells the pName to get the players name!
        format(string, sizeof(string), "--> %s is now AFK",pName); // This is what will send to everyone!
        SendClientMessageToAll(LIGHTBROWN, string); // This is what makes the "string" send in the "COLOR_BLUE"!
        GameTextForPlayer(playerid,"~w~You ~b~are ~r~AFK ~w~now!",3000,5);
        TogglePlayerControllable(playerid, 0); // Makes it so the player cannot move.
        SetPlayerHealth(playerid, 999999.999); // Sets the players health so he is invincible! So noone can kill him.
        return 1;
    }
    //BACK
    if(strcmp(cmdtext, "/back", true) == 0)
    {
        new pName[MAX_PLAYER_NAME]; // Saying pName is the Players Name!
        new string[128]; // Creating the string.
        GetPlayerName(playerid,pName,MAX_PLAYER_NAME); // tells the pName to get the players name!
        format(string, sizeof(string), "--> %s is now BACK",pName); // This is what will send to everyone!
        SendClientMessageToAll(LIGHTBROWN, string); // This is what makes the "string" send in the "COLOR_BLUE"!
        GameTextForPlayer(playerid,"~w~You ~b~are ~r~BACK ~w~now!",3000,5);
        TogglePlayerControllable(playerid, 1); // Makes it so the player can move.
        SetPlayerHealth(playerid, 100); // Sets the players health back to normal. He is now killable.
        return 1;
    }
    //Turn lights on
    if(strcmp(cmdtext, "/lights on",true)==0)
    {
        new vid = GetPlayerVehicleID(playerid);
        if(vid != INVALID_VEHICLE_ID)
        {
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
        }
        return 1;
    }
    //Turn off lights
    if(strcmp(cmdtext, "/lights off",true)==0)
    {
        new vid = GetPlayerVehicleID(playerid);
        if(vid != INVALID_VEHICLE_ID)
        {
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
        }
        return 1;
    }
    //StartEngine
    if(strcmp(cmdtext, "/start engine",true)==0)
    {
        new vid = GetPlayerVehicleID(playerid);
        if(vid != INVALID_VEHICLE_ID)
        {
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
        }
        return 1;
    }
    //Turn off Engine
    if(strcmp(cmdtext, "/stop engine",true)==0)
    {
        new vid = GetPlayerVehicleID(playerid);
        if(vid != INVALID_VEHICLE_ID)
        {
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
        }
        return 1;
    }
    if(strcmp(cmdtext, "/buy phone",true)==0)
    {
        if(IsPlayerInRangeOfPoint(playerid,1,-2235.3987,130.1578,1035.4141))
        {

        }
        else
           {
            SendClientMessage(playerid, 0xAF2800FF,"You have to stand in the pickup");

        }
        return 1;
    }
    if(strcmp(cmdtext, "/stats", true) == 0) // unser Command, kann natьrlich auch anders angeordnet sein jenachdem wie er bei euch im Script definiert ist!
    {
        MyDialogStatsSystem(playerid); // Цffnet unsere Stats :5
        return 1;
    }
    if(strcmp(cmdtext,"/jobs",true)==0)
    {
        if(IsPlayerInRangeOfPoint(playerid,1,2308.8784,-2.1824,26.7422))
        {
            SendClientMessage(playerid,DARKGREEN,"Will come soon..");
        }
        else
        {
            SendClientMessage(playerid, 0xAF2800FF,"You have to stand in the pickup");
        }
        return 1;
    }
    if(strcmp(cmdtext,"/score5",true)==0)
    {
        SetPlayerScore(playerid,5); //Um level zu setzen
        return 1;
    }
    if(strcmp(cmdtext,"/dslsopen",true)==0)
    {
        MoveObject(dslsc, 2846.50195312,-1974.86914062,3.60267448, 2); //object(elecfence_bar) (7)
        SendClientMessage(playerid, WHITE,"You've {FF0000}opened {FAFAFA}the gate!");
        return 1;
    }
    if(strcmp(cmdtext,"/dslsclose",true)==0)
    {
        MoveObject(dslsc, 2846.50195312,-1974.86962891,10.10267448, 2);
        SendClientMessage(playerid, WHITE,"You've {FF0000}closed {FAFAFA}the gate!");
        return 1;
    }
    if(strcmp(cmdtext,"/test",true)==0)
    {
        SendClientMessage(playerid,ORANGE,"This command will give you {FF0000}$500 & -60HP");
        a_GivePlayerMoney(playerid, 500);
        SetPlayerHealth(playerid, 10.0);
        return 1;
    }
    if(strcmp(cmdtext,"/help",true)==0)
    {
        SendClientMessage(playerid,ORANGE,"|________HELP________|");
        SendClientMessage(playerid,ORANGE,"** MAIN ** {FF0000}/about /score5 /afk /back");
        SendClientMessage(playerid,ORANGE,"** FUN ** {FF0000}/test /dslsclose /dslsopen");
        SendClientMessage(playerid,ORANGE,"** CAR ** {FF0000}/start engine /stop engine /lights on /lights off");
        SendClientMessage(playerid,ORANGE,"|____________________|");
        return 1;
    }
    if(strcmp(cmdtext,"/about",true)==0)
    {
        SendClientMessage(playerid,ORANGE,"|________ABOUT________|");
        SendClientMessage(playerid,WHITE,"Crossfire Roleplay Server 0.3c");
        SendClientMessage(playerid,WHITE,"Script: CF-RP v0.1 by ScoOf");
        SendClientMessage(playerid,WHITE,"Server location: Germany");
        SendClientMessage(playerid,WHITE,"mIRC: #crossfire");
        SendClientMessage(playerid,ORANGE,"|_____________________|");
        return 1;
    }
    else
    {
        new stringx[128];
        format(stringx,sizeof(stringx),"There is no %s Command.",cmdtext);
        SendClientMessage(playerid,0x9362A3FF,stringx);
        return 1;
    }
    return 1;
}

I hope that i have helped
Reply
#7

Thanks, didnt test yet but will that fix also the Message that I've done? The "There is no '%s' Command." instead of "Server Unknown Command"?
Reply
#8

Quote:
Originally Posted by ukraine1594
Посмотреть сообщение
Thanks, didnt test yet but will that fix also the Message that I've done? The "There is no '%s' Command." instead of "Server Unknown Command"?
Yes, check the end of the code that i put .


I tested it here and it did not give me errors.


I hope that i have helped
Reply
#9

Sorry, but it doesnt work
Still getting the Message
Reply
#10

Now, i tested it, it have to work:


pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256];
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmd, "/afk", true) == 0)
    {
        new pName[MAX_PLAYER_NAME]; // Saying pName is the Players Name!
        new string[128]; // Creating the string.
        GetPlayerName(playerid,pName,MAX_PLAYER_NAME); // tells the pName to get the players name!
        format(string, sizeof(string), "--> %s is now AFK",pName); // This is what will send to everyone!
        SendClientMessageToAll(LIGHTBROWN, string); // This is what makes the "string" send in the "COLOR_BLUE"!
        GameTextForPlayer(playerid,"~w~You ~b~are ~r~AFK ~w~now!",3000,5);
        TogglePlayerControllable(playerid, 0); // Makes it so the player cannot move.
        SetPlayerHealth(playerid, 999999.999); // Sets the players health so he is invincible! So noone can kill him.
        return 1;
    }
    //BACK
    if(strcmp(cmd, "/back", true) == 0)
    {
        new pName[MAX_PLAYER_NAME]; // Saying pName is the Players Name!
        new string[128]; // Creating the string.
        GetPlayerName(playerid,pName,MAX_PLAYER_NAME); // tells the pName to get the players name!
        format(string, sizeof(string), "--> %s is now BACK",pName); // This is what will send to everyone!
        SendClientMessageToAll(LIGHTBROWN, string); // This is what makes the "string" send in the "COLOR_BLUE"!
        GameTextForPlayer(playerid,"~w~You ~b~are ~r~BACK ~w~now!",3000,5);
        TogglePlayerControllable(playerid, 1); // Makes it so the player can move.
        SetPlayerHealth(playerid, 100); // Sets the players health back to normal. He is now killable.
        return 1;
    }
    //Turn lights on
    if(strcmp(cmd, "/lights on", true) == 0)
    {
        new vid = GetPlayerVehicleID(playerid);
        if(vid != INVALID_VEHICLE_ID)
        {
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
        }
        return 1;
    }
    //Turn off lights
    if(strcmp(cmd, "/lights off", true) == 0)
    {
        new vid = GetPlayerVehicleID(playerid);
        if(vid != INVALID_VEHICLE_ID)
        {
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
        }
        return 1;
    }
    //StartEngine
    if(strcmp(cmd, "/start engine", true) == 0)
    {
        new vid = GetPlayerVehicleID(playerid);
        if(vid != INVALID_VEHICLE_ID)
        {
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
        }
        return 1;
    }
    //Turn off Engine
    if(strcmp(cmd, "/stop engine", true) == 0)
    {
        new vid = GetPlayerVehicleID(playerid);
        if(vid != INVALID_VEHICLE_ID)
        {
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
        }
        return 1;
    }
    if(strcmp(cmd, "/buy phone", true) == 0)
    {
        if(IsPlayerInRangeOfPoint(playerid,1,-2235.3987,130.1578,1035.4141))
        {

        }
        else
           {
            SendClientMessage(playerid, 0xAF2800FF,"You have to stand in the pickup");

        }
        return 1;
    }
    if(strcmp(cmd, "/stats", true) == 0) // unser Command, kann natьrlich auch anders angeordnet sein jenachdem wie er bei euch im Script definiert ist!
    {
        MyDialogStatsSystem(playerid); // Цffnet unsere Stats :5
        return 1;
    }
    if(strcmp(cmd, "/jobs", true) == 0)
    {
        if(IsPlayerInRangeOfPoint(playerid,1,2308.8784,-2.1824,26.7422))
        {
            SendClientMessage(playerid,DARKGREEN,"Will come soon..");
        }
        else
        {
            SendClientMessage(playerid, 0xAF2800FF,"You have to stand in the pickup");
        }
        return 1;
    }
    if(strcmp(cmd, "/score5", true) == 0)
    {
        SetPlayerScore(playerid,5); //Um level zu setzen
        return 1;
    }
    if(strcmp(cmd, "/dslsopen", true) == 0)
    {
        MoveObject(dslsc, 2846.50195312,-1974.86914062,3.60267448, 2); //object(elecfence_bar) (7)
        SendClientMessage(playerid, WHITE,"You've {FF0000}opened {FAFAFA}the gate!");
        return 1;
    }
    if(strcmp(cmd, "/dslsclose", true) == 0)
    {
        MoveObject(dslsc, 2846.50195312,-1974.86962891,10.10267448, 2);
        SendClientMessage(playerid, WHITE,"You've {FF0000}closed {FAFAFA}the gate!");
        return 1;
    }
    if(strcmp(cmd, "/test", true) == 0)
    {
        SendClientMessage(playerid,ORANGE,"This command will give you {FF0000}$500 & -60HP");
        a_GivePlayerMoney(playerid, 500);
        SetPlayerHealth(playerid, 10.0);
        return 1;
    }
    if(strcmp(cmd, "/help", true) == 0)
    {
        SendClientMessage(playerid,ORANGE,"|________HELP________|");
        SendClientMessage(playerid,ORANGE,"** MAIN ** {FF0000}/about /score5 /afk /back");
        SendClientMessage(playerid,ORANGE,"** FUN ** {FF0000}/test /dslsclose /dslsopen");
        SendClientMessage(playerid,ORANGE,"** CAR ** {FF0000}/start engine /stop engine /lights on /lights off");
        SendClientMessage(playerid,ORANGE,"|____________________|");
        return 1;
    }
    if(strcmp(cmd, "/about", true) == 0)
    {
        SendClientMessage(playerid,ORANGE,"|________ABOUT________|");
        SendClientMessage(playerid,WHITE,"Crossfire Roleplay Server 0.3c");
        SendClientMessage(playerid,WHITE,"Script: CF-RP v0.1 by ScoOf");
        SendClientMessage(playerid,WHITE,"Server location: Germany");
        SendClientMessage(playerid,WHITE,"mIRC: #crossfire");
        SendClientMessage(playerid,ORANGE,"|_____________________|");
        return 1;
    }
    else
    {
        new stringx[128];
        format(stringx,sizeof(stringx),"There is no %s Command.",cmdtext);
        SendClientMessage(playerid, 0xAF2800FF,stringx);
    }
    return 1;
}
I hope that i have helped
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)