[Help] OnPlayerCommandText to ZCMD
#1

Hello,

How do I convert this

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    new 
cmd[128], tmp[128], idx;
    
cmd strtok(cmdtextidx);
    if(!
strcmp("/edit"cmdtrue)) COMMAND:edit(playeridparams[])
    {
        
tmp strtok(cmdtextidx);
        if(!
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playeridCBLUE"|- ((ERROR)) You are not in any vehicle. -|");
        if(!
strlen(tmp)) return SendClientMessage(playeridCBLUE"|- ((ERROR)) Use: /edit [objectid] -|");
        new 
ibool:OtherObject;
        for(
0MAX_OBJECTS_PER_EDITi++)
        {
            if(
PlayerData[playerid][ObjectID][i] == -1) break;
            
OtherObject true;
            if(
== (MAX_OBJECTS_PER_EDIT 1)) return SendClientMessage(playeridCBLUE"|- ((ERROR)) You're editing the maximum of objects defined. -|");
        }
        new 
Obj CreateObject(strval(tmp), 0.00.0, -14.00.00.00.0),
        
vId GetPlayerVehicleID(playerid), str[148];
        if(
OtherObject)
        {
            
PlayerData[playerid][ObjectModel][i] = strval(tmp);
            
PlayerData[playerid][EditionID] = i;
            
PlayerData[playerid][ObjectID][i] = Obj;
            
format(strsizeof 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(playeridCBLUEstr);
            
SendClientMessage(playeridCBLUE"|- Use {F40B74}/X /Y or /Z{4E76B1} to adjust the linear offsets -|");
            
SendClientMessage(playeridCBLUE"|- Use {F40B74}/RX /RY or /RZ{4E76B1} to adjust the rotational offsets -|");
            
SendClientMessage(playeridCBLUE"|- Use {F40B74}/EDITION{4E76B1} to switch between objects editions -|");
            
SendClientMessage(playeridCBLUE"|- Use {F40B74}/FREEZE{4E76B1} and {F40B74}/UNFREEZE{4E76B1} to freeze and unfreeze yourself -|");
            
SendClientMessage(playeridCBLUE"|- Use {F40B74}/STOP{4E76B1} to stop some edition. -|");
            
SendClientMessage(playeridCBLUE"|- Use {F40B74}/SAVEOBJ{4E76B1} to save the object to file \"editions.pwn\". -|");
            
ShowPlayerDialog(playerid0DIALOG_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"30true"i"playerid);
        
format(strsizeof 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(playeridCBLUEstr);
        
SendClientMessage(playeridCBLUE"|- Use {F40B74}/X /Y or /Z{4E76B1} to adjust the linear offsets -|");
        
SendClientMessage(playeridCBLUE"|- Use {F40B74}/RX /RY or /RZ{4E76B1} to adjust the rotational offsets -|");
        
SendClientMessage(playeridCBLUE"|- Use {F40B74}/MATERIALS{4E76B1} to choise an object material from the list -|");
        
SendClientMessage(playeridCBLUE"|- Use {F40B74}/MATERIAL{4E76B1} to set an specifc object material -|");
        
SendClientMessage(playeridCBLUE"|- Use {F40B74}/EDITION and /EDITIONS{4E76B1} to switch between objects editions -|");
        
SendClientMessage(playeridCBLUE"|- Use {F40B74}/FREEZE{4E76B1} and {F40B74}/UNFREEZE{4E76B1} to freeze and unfreeze yourself -|");
        
SendClientMessage(playeridCBLUE"|- Use {F40B74}/STOP{4E76B1} to stop some edition. -|");
        
SendClientMessage(playeridCBLUE"|- Use {F40B74}/SAVEOBJ{4E76B1} to save the object to file \"editions.pwn\". -|");
        return 
true;
    } 
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.
Reply
#2

https://sampwiki.blast.hk/wiki/Command_C...trcmp_to_z_cmd
Reply
#3

Quote:
Originally Posted by AMouldyLemon
Посмотреть сообщение
Please re-read my message and if you know that how to use these parameters into ZCMD then please come up with your help and I'll probably rep+ you.
Reply
#4

use sscanf
Reply
#5

Quote:
Originally Posted by AlexeyTrekkkk
Посмотреть сообщение
use sscanf
I tried to use it but I am getting a lot of errors while using and I also tried to read the sscanf tutorial but it's still happening or will do a code for me and which includes are to be added and where do I add this code in which public function?
Reply
#6

try this

pawn Код:
#include <zcmd> //must be on top of your script

CMD:edit(playerid,params[])    
{
        new objectid;
        if(sscanf(params, "d",objectid)) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) Use: /edit [objectid] -|");
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) You are not in any vehicle. -|");
        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(objectid, 0.0, 0.0, -14.0, 0.0, 0.0, 0.0),
        vId = GetPlayerVehicleID(playerid), str[148];

        if(OtherObject)
        {
            PlayerData[playerid][ObjectModel][i] = objectid;
            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 -|", objectid, 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] = objectid;
        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 -|", objecid, 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;
    }
Reply
#7

pawn Код:
#include <a_samp>
#include <zcmd>

CMD:edit(playerid, params[])
{
        new cmd[128], tmp[128], idx;
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) You are not in any vehicle. -|");
        if(sscanf(params, "u", amount))  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;
    }
Untested
Reply
#8

Quote:
Originally Posted by SturtIndia
Посмотреть сообщение
pawn Код:
#include <a_samp>
#include <zcmd>

CMD:edit(playerid, params[])
{
        new cmd[128], tmp[128], idx;
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) You are not in any vehicle. -|");
        if(sscanf(params, "u", amount))  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;
    }
Untested
Thanks, but do I have to #include <sscanf2> ? or not?

And How to add sscanf in plugin to get my script working?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)