converting strcmp to zmcd
#1

SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator!");
return 1;
}
}
if(strcmp(cmd, "/tickets", true) == 0)
{
if(PInfo[playerid][Tickets] == 0)
{
SendClientMessage(playerid, COLOR_ERROR, "You do not have any tickets! [Tickets are given out by administrators for reporting rulebreakers and helping out.]");
return 1;
}
else
{
format(string,sizeof(string),"You have a total of {1B8AE4}%d{FFFFFF} tickets. You can /repair, /refuel or /cancel for free! (Each action uses 1 ticket)",PInfo[playerid][Tickets]);
SendClientMessage(playerid, COLOR_WHITE, string);
return 1;
}
}
if(strcmp(cmd, "/giveticket", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PInfo[playerid][AdminLevel] < 2)
{
SendClientMessage(playerid, COLOR_ERROR, "You are not an admin !");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ERROR, "Syntax: /giveticket (playername/id) (reason)");
return 1;
}
new giveplayerid;
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_ERROR, "Syntax: /giveticket (playerid/name) (reason)");
return 1;
}
PInfo[giveplayerid][Tickets]=PInfo[giveplayerid][Tickets]+1;
ServerTickets = ServerTickets+1;
format(string, sizeof(string), "Administrator {1B8AE4}%s(%d){FFFFFF} has given a ticket to {1B8AE4}%s {FFFFFF}for {1B8AE4}%s", PlayerName(playerid),playerid,PlayerName(giveplaye rid), (result));
SendClientMessageToAll(COLOR_WHITE, string);
SaveStuff();
AdminLog(playerid, "/giveticket", "Awarded Ticket", PlayerName(giveplayerid));
TicketLog(PlayerName(playerid), PlayerName(giveplayerid), (result));
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_ERROR, "Could not find player !");
return 1;
}

how to convert these command to zcmd
Reply
#2

A ZCMD command can look like so:
Code:
COMMAND:ticket(playerid, params[])
And then use sscanf instead of strtok, read some tutorials on more information about using sscanf.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)