11.04.2017, 18:09
A friend of mine asked me to convert this command to zcmd which i taught it was going to be easy, but i have no experience with strcmp so i would just like someone to give me some explanation on some lines
Can someone explain what those line mean and what it would look like in zcmd?
PHP код:
if(strcmp(cmd, "/bet", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(BizzInfo[PlayerInfo[playerid][InBusiness]][bType] == 5)
{
if(!IsAtRLTable(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You are not near a Roulette table!");
return 1;
}
new ball = random(4);
tmp = strtok(cmdtext, idx);//what does this line do
if(!strlen(tmp))//what does this line do
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bet [red/black] [amount]");
return 1;
}
if(strcmp(tmp,"red",true) == 0)//what does this line do
{
tmp = strtok(cmdtext, idx);//what does this line do
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bet [red/black] [amount]");
return 1;
}
new mred = strvalEx(tmp);//what does this line do
if(mred < 1 || mred > 10000)
{
SendClientMessage(playerid, COLOR_GREY, " Bet can't be below $0 or above $10,000!");
return 1;
}
GetPlayerName(playerid, sendername, sizeof(sendername));
if(ball == 1)
{
if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger beats on red and won.");
else format(string, sizeof(string), "* %s bets on red and won.", sendername);
ProxDetector(5.0, playerid, string, COLOR_LIGHTGREEN,COLOR_LIGHTGREEN,COLOR_LIGHTGREEN,COLOR_LIGHTGREEN,COLOR_LIGHTGREEN);
format(string, sizeof(string), "* You won $%d.", mred);
SendClientMessage(playerid, COLOR_GREEN, string);
PlayerInfo[playerid][pCash] += mred;
GivePlayerMoney(playerid, mred);
BizzInfo[PlayerInfo[playerid][InBusiness]][bTill] -= mred;
}
else
{
if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger beats on red and lost.");
else format(string, sizeof(string), "* %s bets on red and lost.", sendername);
ProxDetector(5.0, playerid, string, COLOR_LIGHTGREEN,COLOR_LIGHTGREEN,COLOR_LIGHTGREEN,COLOR_LIGHTGREEN,COLOR_LIGHTGREEN);
format(string, sizeof(string), "* You lost $%d.", mred);
SendClientMessage(playerid, COLOR_LIGHTRED, string);
PlayerInfo[playerid][pCash] -= mred;
GivePlayerMoney(playerid, -mred);
BizzInfo[PlayerInfo[playerid][InBusiness]][bTill] += mred;
}
}
if(strcmp(tmp,"black",true) == 0)//what does this line do
{
tmp = strtok(cmdtext, idx);//what does this line do
if(!strlen(tmp))//what does this line do
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bet [black/red] [amount]");
return 1;
}
new mblack = strvalEx(tmp);
if(mblack < 1 || mblack > 10000)
{
SendClientMessage(playerid, COLOR_GREY, " Bet can't be below $0 or above $10,000!");
return 1;
}
GetPlayerName(playerid, sendername, sizeof(sendername));
if(ball == 1)
{
if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger beats on black and won.");
else format(string, sizeof(string), "* %s bets on black and won.", sendername);
ProxDetector(5.0, playerid, string, COLOR_LIGHTGREEN,COLOR_LIGHTGREEN,COLOR_LIGHTGREEN,COLOR_LIGHTGREEN,COLOR_LIGHTGREEN);
format(string, sizeof(string), "* You won $%d.", mblack);
SendClientMessage(playerid, COLOR_GREEN, string);
PlayerInfo[playerid][pCash] += mblack;
GivePlayerMoney(playerid, mblack);
BizzInfo[PlayerInfo[playerid][InBusiness]][bTill] -= mblack;
}
else
{
if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger beats on black and lost.");
else format(string, sizeof(string), "* %s bets on black and lost.", sendername);
ProxDetector(5.0, playerid, string, COLOR_LIGHTGREEN,COLOR_LIGHTGREEN,COLOR_LIGHTGREEN,COLOR_LIGHTGREEN,COLOR_LIGHTGREEN);
format(string, sizeof(string), "* You lost $%d.", mblack);
SendClientMessage(playerid, COLOR_LIGHTRED, string);
PlayerInfo[playerid][pCash] -= mblack;
GivePlayerMoney(playerid, -mblack);
BizzInfo[PlayerInfo[playerid][InBusiness]][bTill] += mblack;
}
}
}