SA-MP Forums Archive
Command doesn't work - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Command doesn't work (/showthread.php?tid=190686)



HELP pls ! Command problem. - .sparkY - 16.11.2010

Код:
COMMAND:makeadmin(playerid,params[])
{
    new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME], level, giveplayerid;
    if(IsPlayerAdmin(playerid))
    {
        if(!sscanf(params,"ud",giveplayer,level))
        {
            if(giveplayerid != INVALID_PLAYER_ID)
            {
                GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                GetPlayerName(playerid, player, sizeof(player));
                PlayerInfo[giveplayerid][AdminLvl] = level;
                printf("Admin %s made %s a level %d admin.", player, giveplayer, level);
                format(string, sizeof(string), "You are now an administrator level %d thanks to %s.", level,  player);
                SendClientMessage(giveplayerid, 0x00C2ECFF, string);
                format(string, sizeof(string), "You have given %s level %d admin.",  giveplayer,PlayerInfo[giveplayerid][AdminLvl]);
                SendClientMessage(playerid, 0x00C2ECFF, string);
            }
            else
            {
                format(string, sizeof(string), "%i is not an active player.", giveplayerid);
                SendClientMessage(playerid, 0xE60000FF, string);
                return 1;
            }
        }
        else
        {
            SendClientMessage(playerid, Crvena, "USAGE: /makeadmin [playerid] [level]");
            SendClientMessage(playerid, Crvena, "FUNCTION: Player will be an admin.");
            return 1;
        }
    }
    else SendClientMessage(playerid, 0xE60000FF, "You are not a lead admin!");
    return 1;
}
Here's the command. When I put it in my GM, my login / register doesn't work :S I just pressed spawn, and command doesn't work... Nothing happends when I type in /mekadmin.

Help


Re: Command doesn't work - Dj_maryo1993 - 16.11.2010

From my undestanding you cannot use the old-fashion commands(like if(strcmp(cmd, "/makeadmin", true) == 0)) while using zcmd , so use zcmd for all your commands


Re: Command doesn't work - .sparkY - 16.11.2010

Quote:
Originally Posted by Dj_maryo1993
Посмотреть сообщение
From my undestanding you cannot use the old-fashion commands(like if(strcmp(cmd, "/makeadmin", true) == 0)) while using zcmd , so use zcmd for all your commands
no. I only have this command In my GM. And it doesn't work. It shows no errors and no warrnings, but when that command is in my gamemode, when I start my home server, my login / register doesn't work :S


Re: Command doesn't work - iggy1 - 16.11.2010

You get "unknown command" or what happens when you type the command?


Re: Command doesn't work - .sparkY - 16.11.2010

nothing happends... That command is the only command in my GameMode, it's on the end of GM. When I put it in my GM, and go to my server, My Login dialog doesn't show up -.-


Re: Command doesn't work - .sparkY - 16.11.2010

Oh come on ! No1 can help me ?! I tried this too... This is my command now :
Quote:

public OnPlayerCommandText(playerid, cmdtext[])
{
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new cmd[256];
new string[128];
new tmp[256];
new idx;



if(strcmp(cmd, "/makeadmin", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, Crvena, "KORISTENJE: /makeadmin [playerid/DioImena] [level(1-3)]");
return 1;
}
new para1;
new level;
para1 = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
level = strval(tmp);
if (PlayerInfo[playerid][AdminLvl] >= 1337 || IsPlayerAdmin(playerid))
{
if(IsPlayerConnected(para1))
{
if(para1 != INVALID_PLAYER_ID)
{
GetPlayerName(para1, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
PlayerInfo[para1][AdminLvl] = level;
format(string, sizeof(string), "Postavljen si za admina level %d od %s", level, sendername);
SendClientMessage(para1, Crvena, string);
format(string, sizeof(string), "Postavio si %s na admin level %d.", giveplayer,level);
SendClientMessage(playerid, Crvena, string);
}
}
}
else
{
SendClientMessage(playerid, Crvena, "[ERROR]: Samo administratori mogu koristiti ovu komandu.");
}
}
return 1;
}
return 0;
}

I go ingame, everything's normal, but when I type in /makeadmin, nothing happends !


Re: Command doesn't work - .sparkY - 16.11.2010

oh great. So many scripters, no1 can solve my problem -.- Thanks a lot.


Re: Command doesn't work - Kidemo - 16.11.2010

PHP код:
if(!strcmp(cmdtext"/makeadmin"true))
{
    new 
player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME], levelgiveplayerid;
    if(
IsPlayerAdmin(playerid))
    {
        if(!
sscanf(params,"ud",giveplayer,level))
        {
            if(
giveplayerid != INVALID_PLAYER_ID)
            {
                
GetPlayerName(giveplayeridgiveplayersizeof(giveplayer));
                
GetPlayerName(playeridplayersizeof(player));
                
PlayerInfo[giveplayerid][AdminLvl] = level;
                
printf("Admin %s made %s a level %d admin."playergiveplayerlevel);
                
format(stringsizeof(string), "You are now an administrator level %d thanks to %s."level,  player);
                
SendClientMessage(giveplayerid0x00C2ECFFstring);
                
format(stringsizeof(string), "You have given %s level %d admin.",  giveplayer,PlayerInfo[giveplayerid][AdminLvl]);
                
SendClientMessage(playerid0x00C2ECFFstring);
            }
            else
            {
                
format(stringsizeof(string), "%i is not an active player."giveplayerid);
                
SendClientMessage(playerid0xE60000FFstring);
                return 
1;
            }
        }
        else
        {
            
SendClientMessage(playeridCrvena"USAGE: /makeadmin [playerid] [level]");
            
SendClientMessage(playeridCrvena"FUNCTION: Player will be an admin.");
            return 
1;
        }
    }
    else 
SendClientMessage(playerid0xE60000FF"You are not a lead admin!");
    return 
1;




Re: Command doesn't work - .sparkY - 16.11.2010

@Linhanh : The command you gave me shows an error "Undefined symbol params", So i Put it lik this :


Quote:

CMD:makeadmin(playerid, params[])
{
new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME], level, giveplayerid;
new string[128];
if(IsPlayerAdmin(playerid))
{
if(!sscanf(params,"ud",giveplayer,level))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, player, sizeof(player));
PlayerInfo[giveplayerid][AdminLvl] = level;
printf("Admin %s made %s a level %d admin.", player, giveplayer, level);
format(string, sizeof(string), "You are now an administrator level %d thanks to %s.", level, player);
SendClientMessage(giveplayerid, 0x00C2ECFF, string);
format(string, sizeof(string), "You have given %s level %d admin.", giveplayer,PlayerInfo[giveplayerid][AdminLvl]);
SendClientMessage(playerid, 0x00C2ECFF, string);
}
else
{
format(string, sizeof(string), "%i is not an active player.", giveplayerid);
SendClientMessage(playerid, 0xE60000FF, string);
return 1;
}
}
else
{
SendClientMessage(playerid, Crvena, "USAGE: /makeadmin [playerid] [level]");
SendClientMessage(playerid, Crvena, "FUNCTION: Player will be an admin.");
return 1;
}
}
else SendClientMessage(playerid, 0xE60000FF, "You are not a lead admin!");
return 1;
}

And, when I go into my server, my login dialog doesn't show up -.-' I just click Spawn, and get in the game, but the command still doesn't work -.-


Re: Command doesn't work - .sparkY - 17.11.2010

So many scripters, and no1 can solve my problem and help me -.- nice. -.-