16.05.2013, 16:39
Well, Hello everyone. I just started using zcmd & sscanf instead of strcmp & strtok and I am having some problems. I will explain everything below. Here are two commands I took for example:
Those both command's second character "u" is working perfectly, example, when you type /givemoney, it shows its return. But when it comes to third character "i" It sends me "Unknown command" or Command return I made if(giveplayerid == INVALID_PLAYER_ID).
NOTE: I visited a lot of threads with people having this problem. Their solution was replacing INVALID_PLAYER_ID with IsPlayerConnected. Still says the same. I also upgraded sscanf's version to the newest one.
I was working on CMD:makeadmin for a few days and still got nothing, third character isnt working. I would like someone to help me fix the commands and explain me how to make third character "i" work.
I also attempted copying commands from other ZCMD Gamemodes I found, but I got the same error.
And the last thing I did was replacing places to functions "if".
PHP Code:
CMD:makeadmin(playerid, params[])
{
if(PlayerInfo[playerid][AdminLevel] < 6 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_WHITE, "You are not authorized to use this command!");
new giveplayerid, amount, string[128], sendername[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME];
if(sscanf(params, "ui", giveplayerid, amount)) return SendClientMessage(playerid, -1, "USAGE: /makeadmin [playerid] [rank[1 - 6]]");
{
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid,sendername,sizeof(sendername));
GetPlayerName(giveplayerid,name,sizeof(name));
format(string, sizeof(string), "AdmCmd: %s was made a level %d administrator by %s.", name, amount, sendername);
//ABroadCast(COLOR_LIGHTRED,string,1);
PlayerInfo[giveplayerid][AdminLevel] = amount;
format(string, sizeof(string), "MAKE-ADMIN: %s has made %s a level %i adminstrator.",playerid,giveplayerid, PlayerInfo[giveplayerid][AdminLevel]);
//Log("logs/administration.log", string);
}
}
if(amount > 6) return SendClientMessage(playerid, COLOR_WHITE,"There are only 6 administrator levels!");
if(amount < 0) return SendClientMessage(playerid, COLOR_WHITE, "Invalid administrator level!");
// if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, -1, "Error: Player Not Connected");
if(giveplayerid == INVALID_PLAYER_ID)
{
SendClientMessage(playerid, COLOR_RED, " That player id/name doesnt exist or that player isnt online atm.");
}
//if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE,"Invalid player ID.");
return 1;
}
CMD:givemoney(playerid, params[])
{
new targetid, ammount;
if(sscanf(params,"ui", targetid, ammount)) return SendClientMessage(playerid, 0xFFFFFFF,"Syntax error.Correct usage: /givemoney [PlayerID] [Ammount]");
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFFF,"Error: This command is only for RCON Admins");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFFFFFFF,"That player is not connected to your server!");
else
{
GivePlayerMoney(targetid, ammount); // So it will give the targetid the ammount you want.
}
return 1;
}
NOTE: I visited a lot of threads with people having this problem. Their solution was replacing INVALID_PLAYER_ID with IsPlayerConnected. Still says the same. I also upgraded sscanf's version to the newest one.
I was working on CMD:makeadmin for a few days and still got nothing, third character isnt working. I would like someone to help me fix the commands and explain me how to make third character "i" work.
I also attempted copying commands from other ZCMD Gamemodes I found, but I got the same error.
And the last thing I did was replacing places to functions "if".