24.01.2013, 17:06
(
Последний раз редактировалось Roach_; 24.01.2013 в 19:13.
)
For first, why do you want to change that, ZCMD is more faster than strcmp..
Whatever..
You need this function:
Add this to the OnPlayerCommandText callback(at the beginning of the callback):
The commands would be like this:
Whatever..
You need this function:
pawn Код:
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
pawn Код:
new cmd[128], idx;
cmd = strtok(cmdtext, idx);
pawn Код:
if(!strcmp(cmd, "/addpickup", true))
{
new tmp[128], pID, tID;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFFFFF,"USAGE: /AddPickup < Pickup ID > < Type >");
pID = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFFFFF,"USAGE: /AddPickup < Pickup ID > < Type >");
tID = strval(tmp);
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
CreateSavedPickup(pID, tID, X, Y, Z);
new Msg[128];
format(Msg, sizeof Msg, "Pickup Successfully Created. (Model: %d) (Type: %d)", pID, tID);
SendClientMessage(playerid, 0xFFFFFF, Msg);
return 1;
}
pawn Код:
if(!strcmp(cmd, "/removepickup", true))
{
new tmp[128], PickupID;
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFFFFF,"USAGE: /RemovePickup < Pickup ID >");
PickupID = strval(tmp);
if(!IsValidDynamicPickup(pInfo[PickupID][PID])) return SendClientMessage(playerid, 0xFFFFFFF, "ERROR: Pickup Does Not Exist!");
DestroyDynamicPickup(pInfo[PickupID][PID]);
format(pFile, sizeof(pFile), PICKUPFILE, PickupID);
if(dini_Exists(pFile))
{
dini_Remove(pFile);
dini_IntSet(pIDFile, "Total Pickups:", dini_Int(pIDFile, "Total Pickups:")-1);
}
new Msg[128];
format(Msg,sizeof(Msg),"Pickup ID: %d Was 1Destroyed!",PickupID);
SendClientMessage(playerid, 0xFFFFFFF,Msg);
return 1;
}