21.01.2014, 13:35
Hello,
I have some problems with my gamemode I'm using zcmd and I have both CMD:command(playerid, params[]) and OnPlayerCommandRecived so when i type for example /skills it shows me Unknown Command but if I move it to zcmd everything works fine. Can you help me please ?
It shows Unknown Command here.
And when I move it to CMD
ay(playerid, params[]) it works fine.
And here is debug fro /pay
Edit: OnPlayerCommandText is removed
I have some problems with my gamemode I'm using zcmd and I have both CMD:command(playerid, params[]) and OnPlayerCommandRecived so when i type for example /skills it shows me Unknown Command but if I move it to zcmd everything works fine. Can you help me please ?
It shows Unknown Command here.
pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
new cmd[128];
new giveplayerid, moneys, idx;
cmd = strtok(cmdtext, idx);
strmid(sendername, PlayerName(playerid), 0, MAX_PLAYER_NAME);
printf("[cmd] [%s] %s", sendername, cmdtext);
if(strcmp(cmd, "/pay", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pay [playerid/PartOfName] [amount]");
return 1;
}
giveplayerid = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pay [playerid/PartOfName] [amount]");
return 1;
}
moneys = strvalEx(tmp);
if(moneys > 1000 && PlayerInfo[playerid][pLevel] < 2)
{
SendClientMessage(playerid, COLOR_GRAD1, " You must be level 2 to pay more than $1000 at a time !");
return 1;
}
if(moneys < 1 || moneys > 100000)
{
SendClientMessage(playerid, COLOR_GRAD1, " You can't pay under $1 or more than $100,000 at a time !");
return 1;
}
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid == playerid) { SendClientMessage(playerid, COLOR_GREY, " You can't pay money to yourself !"); return 1; }
if(giveplayerid != INVALID_PLAYER_ID)
{
if(IsPlayerInRangeOfPlayer(5.0, playerid, giveplayerid) && (GetPlayerState(giveplayerid) != PLAYER_STATE_SPECTATING))
{
strmid(sendername, PlayerRPName(playerid), 0, MAX_PLAYER_NAME);
strmid(giveplayer, PlayerRPName(giveplayerid), 0, MAX_PLAYER_NAME);
new playermoney = PlayerInfo[playerid][pCash];
if(moneys > 0 && playermoney >= moneys)
{
PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]-moneys;
GivePlayerMoney(playerid, (0 - moneys));
PlayerInfo[giveplayerid][pCash] = PlayerInfo[giveplayerid][pCash]+moneys;
GivePlayerMoney(giveplayerid, moneys);
format(string, sizeof(string), " You have paid $%d to %s.",moneys,giveplayer);
SendClientMessage(playerid, COLOR_GRAD1, string);
format(string, sizeof(string), " You have recieved $%d from %s.", moneys,sendername);
SendClientMessage(giveplayerid, COLOR_GRAD1, string);
if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger takes out some cash, and hands it to %s.",giveplayer);
else format(string, sizeof(string), "* %s takes out some cash, and hands it to %s.", sendername,giveplayer);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
PlayerPlaySound(giveplayerid, 1052, 0.0, 0.0, 0.0);
new plrIP[16];
new giveplrIP[16];
GetPlayerIp(playerid, plrIP, sizeof(plrIP));
GetPlayerIp(giveplayerid, giveplrIP, sizeof(giveplrIP));
format(string, sizeof(string), "%s (IP:%s) (Key:%s) (ConTime:%d) has paid $%d to %s (IP:%s) (Key:%s)", sendername,plrIP,PlayerInfo[playerid][pKey], PlayerInfo[playerid][pConnectTime],moneys,giveplayer,giveplrIP,PlayerInfo[giveplayerid][pKey]);
PayLog(string);
strmid(LastPaid[playerid],giveplayer,0,strlen(giveplayer));
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " Invalid transaction amount !");
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " You're too far away !");
}
}
}
else
{
format(string, sizeof(string), " %d is not an active player !", giveplayerid);
SendClientMessage(playerid, COLOR_GRAD1, string);
}
}
return 1;
}
return 1;
}
![Tongue](images/smilies/razz.gif)
pawn Код:
CMD:pay(playerid, params[])
{
new targetid, amount;
if(sscanf(params, "ui", targetid, amount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pay [playerid/PartOfName] [amount]");
if(amount > 1000 && PlayerInfo[playerid][pLevel] < 2) return SendClientMessage(playerid, COLOR_GRAD1, " You must be level 2 to pay more than $1000 at a time !");
if(amount < 1 || amount > 100000) return SendClientMessage(playerid, COLOR_GRAD1, " You can't pay under $1 or more than $100,000 at a time !");
if(targetid == playerid) return SendClientMessage(playerid, COLOR_GREY, " You can't pay money to yourself !");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GRAD1, " Invalid Player ID!");
if(IsPlayerInRangeOfPlayer(5.0, playerid, targetid) && (GetPlayerState(targetid) != PLAYER_STATE_SPECTATING))
{
new playermoney = PlayerInfo[playerid][pCash];
if(amount > 0 && playermoney >= amount)
{
PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]-amount;
GivePlayerMoney(playerid, (0 - amount));
PlayerInfo[targetid][pCash] = PlayerInfo[targetid][pCash]+amount;
GivePlayerMoney(targetid, amount);
format(string, sizeof(string), " You have paid $%d to %s.",amount,PlayerRPName(targetid));
SendClientMessage(playerid, COLOR_GRAD1, string);
format(string, sizeof(string), " You have recieved $%d from %s.", amount,PlayerRPName(playerid));
SendClientMessage(targetid, COLOR_GRAD1, string);
if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger takes out some cash, and hands it to %s.",giveplayer);
else format(string, sizeof(string), "* %s takes out some cash, and hands it to %s.", PlayerRPName(playerid),PlayerRPName(targetid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
PlayerPlaySound(targetid, 1052, 0.0, 0.0, 0.0);
new plrIP[16];
new giveplrIP[16];
GetPlayerIp(playerid, plrIP, sizeof(plrIP));
GetPlayerIp(targetid, giveplrIP, sizeof(giveplrIP));
format(string, sizeof(string), "%s (IP:%s) (Key:%s) (ConTime:%d) has paid $%d to %s (IP:%s) (Key:%s)", PlayerRPName(playerid),plrIP,PlayerInfo[playerid][pKey], PlayerInfo[playerid][pConnectTime],amount,PlayerRPName(targetid),giveplrIP,PlayerInfo[targetid][pKey]);
PayLog(string);
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " Invalid transaction amount !");
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " You're too far away !");
}
return 1;
}
Код:
[cmd] [Marcas_Miller] /pay