23.07.2014, 09:16
Hello,
How do I convert this
to zcmd.
Note: I want to use the following below parameters cause it is in my command "/edit" code.
1. cmdtext[] for cmd = strtok(cmdtext, idx);
2. cmd[128] for if(!strcmp("/edit", cmd, true))
Actually my program is compiled fine but it is not working in-game. Any help will be appreciated. I was looking for the solution on SAMP forums but I didn't find it so I am here to request a help from you. Thanks.
How do I convert this
PHP код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128], tmp[128], idx;
cmd = strtok(cmdtext, idx);
if(!strcmp("/edit", cmd, true)) COMMAND:edit(playerid, params[])
{
tmp = strtok(cmdtext, idx);
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) You are not in any vehicle. -|");
if(!strlen(tmp)) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) Use: /edit [objectid] -|");
new i, bool:OtherObject;
for(i = 0; i < MAX_OBJECTS_PER_EDIT; i++)
{
if(PlayerData[playerid][ObjectID][i] == -1) break;
OtherObject = true;
if(i == (MAX_OBJECTS_PER_EDIT - 1)) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) You're editing the maximum of objects defined. -|");
}
new Obj = CreateObject(strval(tmp), 0.0, 0.0, -14.0, 0.0, 0.0, 0.0),
vId = GetPlayerVehicleID(playerid), str[148];
if(OtherObject)
{
PlayerData[playerid][ObjectModel][i] = strval(tmp);
PlayerData[playerid][EditionID] = i;
PlayerData[playerid][ObjectID][i] = Obj;
format(str, sizeof str, "|- Editing the object {F40B74}%d{4E76B1}, edition id {F40B74}%d{4E76B1}. Use KEY_LEFT, KEY_RIGHT and KEY_FIRE to adjust the offset's -|", strval(tmp), i);
SendClientMessage(playerid, CBLUE, str);
SendClientMessage(playerid, CBLUE, "|- Use {F40B74}/X /Y or /Z{4E76B1} to adjust the linear offsets -|");
SendClientMessage(playerid, CBLUE, "|- Use {F40B74}/RX /RY or /RZ{4E76B1} to adjust the rotational offsets -|");
SendClientMessage(playerid, CBLUE, "|- Use {F40B74}/EDITION{4E76B1} to switch between objects editions -|");
SendClientMessage(playerid, CBLUE, "|- Use {F40B74}/FREEZE{4E76B1} and {F40B74}/UNFREEZE{4E76B1} to freeze and unfreeze yourself -|");
SendClientMessage(playerid, CBLUE, "|- Use {F40B74}/STOP{4E76B1} to stop some edition. -|");
SendClientMessage(playerid, CBLUE, "|- Use {F40B74}/SAVEOBJ{4E76B1} to save the object to file \"editions.pwn\". -|");
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Information", "Do you wish create a object in the same position of the last?", "Yes", "No");
return true;
}
PlayerData[playerid][VehicleID] = vId;
PlayerData[playerid][ObjectModel][i] = strval(tmp);
PlayerData[playerid][EditionID] = i;
PlayerData[playerid][OffSetX][PlayerData[playerid][EditionID]] = 0.0;
PlayerData[playerid][OffSetY][PlayerData[playerid][EditionID]] = 0.0;
PlayerData[playerid][OffSetZ][PlayerData[playerid][EditionID]] = 0.0;
PlayerData[playerid][OffSetRX][PlayerData[playerid][EditionID]] = 0.0;
PlayerData[playerid][OffSetRY][PlayerData[playerid][EditionID]] = 0.0;
PlayerData[playerid][OffSetRZ][PlayerData[playerid][EditionID]] = 0.0;
PlayerData[playerid][ObjectID][i] = Obj;
MaterialData[playerid][PlayerData[playerid][EditionID]][MaterialModel] = 0;
MaterialData[playerid][PlayerData[playerid][EditionID]][MaterialTXDName] = EOS;
MaterialData[playerid][PlayerData[playerid][EditionID]][MaterialTEXName] = EOS;
PlayerData[playerid][TimerID] = SetTimerEx("GetKeys", 30, true, "i", playerid);
format(str, sizeof str, "|- Editing the object {F40B74}%d{4E76B1}, edition id {F40B74}%d{4E76B1}. Use KEY_LEFT, KEY_RIGHT and KEY_FIRE to adjust the offset's -|", strval(tmp), i);
SendClientMessage(playerid, CBLUE, str);
SendClientMessage(playerid, CBLUE, "|- Use {F40B74}/X /Y or /Z{4E76B1} to adjust the linear offsets -|");
SendClientMessage(playerid, CBLUE, "|- Use {F40B74}/RX /RY or /RZ{4E76B1} to adjust the rotational offsets -|");
SendClientMessage(playerid, CBLUE, "|- Use {F40B74}/MATERIALS{4E76B1} to choise an object material from the list -|");
SendClientMessage(playerid, CBLUE, "|- Use {F40B74}/MATERIAL{4E76B1} to set an specifc object material -|");
SendClientMessage(playerid, CBLUE, "|- Use {F40B74}/EDITION and /EDITIONS{4E76B1} to switch between objects editions -|");
SendClientMessage(playerid, CBLUE, "|- Use {F40B74}/FREEZE{4E76B1} and {F40B74}/UNFREEZE{4E76B1} to freeze and unfreeze yourself -|");
SendClientMessage(playerid, CBLUE, "|- Use {F40B74}/STOP{4E76B1} to stop some edition. -|");
SendClientMessage(playerid, CBLUE, "|- Use {F40B74}/SAVEOBJ{4E76B1} to save the object to file \"editions.pwn\". -|");
return true;
}
Note: I want to use the following below parameters cause it is in my command "/edit" code.
1. cmdtext[] for cmd = strtok(cmdtext, idx);
2. cmd[128] for if(!strcmp("/edit", cmd, true))
Actually my program is compiled fine but it is not working in-game. Any help will be appreciated. I was looking for the solution on SAMP forums but I didn't find it so I am here to request a help from you. Thanks.