PDA

View Full Version : help me to convert cmd


monisoft
11/02/2017, 06:44 PM
Hello
I want to transform this code (zcmd to strcmp) please help me how to do it anyway.
CMD:createactor(playerid,params[]) {
new actorName[24],skin;
if(sscanf(params,"is[24]",skin,actorName)) return SendClientMessage(playerid,COLOR_GREY,"Usage: /createactor [skinid] [name] ");
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);

new animlib[32];
new animname[32];

GetAnimationName(GetPlayerAnimationIndex(playerid) ,animlib,32,animname,32);

sql_CreateActor(actorName, skin, x,y,z,a, animlib, animname);

new string[128];
format(string,sizeof(string), "New actor created. Skin ID: %i Name: %s. Type /reloadactors to reload all actors",skin,actorName);
SendClientMessage(playerid,COLOR_GREY,string);
return true;
}

Sew_Sumi
11/02/2017, 06:59 PM
That's going backwards really. You'd be better off converting the strcmp to zcmd.

aymane123
11/02/2017, 07:58 PM
yup zcmd easy,fast.

monisoft
11/02/2017, 08:01 PM
:| plz help me to convert zcmd to strcmp

RyderX
11/02/2017, 08:14 PM
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/createactor"))
{
new actorName[24],skin;
if(sscanf(params,"is[24]",skin,actorName)) return SendClientMessage(playerid,COLOR_GREY,"Usage: /createactor [skinid] [name] ");
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);

new animlib[32];
new animname[32];

GetAnimationName(GetPlayerAnimationIndex(playerid) ,animlib,32,animname,32);

sql_CreateActor(actorName, skin, x,y,z,a, animlib, animname);

new string[128];
format(string,sizeof(string), "New actor created. Skin ID: %i Name: %s. Type /reloadactors to reload all actors",skin,actorName);
SendClientMessage(playerid,COLOR_GREY,string);
return 1;
}
return 0;
}

YouHack
11/02/2017, 08:53 PM
As they said ZCMD is too much faster than strcmp, you'll notice it in the future,
anyway here is your CMD ( under OnPlayerCommandText )

if(strcmp(cmd, "/createactor", true) == 0)
{
new actorName[24],skin;
if(sscanf(params,"is[24]",skin,actorName)) return SendClientMessage(playerid,COLOR_GREY,"Usage: /createactor [skinid] [name] ");
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);

new animlib[32];
new animname[32];

GetAnimationName(GetPlayerAnimationIndex(playerid) ,animlib,32,animname,32);

sql_CreateActor(actorName, skin, x,y,z,a, animlib, animname);

new string[128];
format(string,sizeof(string), "New actor created. Skin ID: %i Name: %s. Type /reloadactors to reload all actors",skin,actorName);
SendClientMessage(playerid,COLOR_GREY,string);
return 1;
}

monisoft
12/02/2017, 03:19 PM
Yes you are right I will have to change their code.
I'm errors when compiling the catalog!
error 017: undefined symbol "params"

Macronix
12/02/2017, 05:50 PM
if(strcmp(cmd, "/createactor", true) == 0)
{
new actorName[24],skin;
if(sscanf(cmd[13],"is[24]",skin,actorName)) return SendClientMessage(playerid,COLOR_GREY,"Usage: /createactor [skinid] [name] ");
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);

new animlib[32];
new animname[32];

GetAnimationName(GetPlayerAnimationIndex(playerid) ,animlib,32,animname,32);

sql_CreateActor(actorName, skin, x,y,z,a, animlib, animname);

new string[128];
format(string,sizeof(string), "New actor created. Skin ID: %i Name: %s. Type /reloadactors to reload all actors",skin,actorName);
SendClientMessage(playerid,COLOR_GREY,string);
return 1;
}

sKenzi1996
12/02/2017, 05:54 PM
Sorry for my question: Why? Why you do that?

monisoft
12/02/2017, 06:14 PM
if(strcmp(cmd, "/createactor", true) == 0)
{
new actorName[24],skin;
if(sscanf(cmd,"is[24]",skin,actorName)) return SendClientMessage(playerid,COLOR_GREY,"Usage: /createactor [skinid] [name] ");
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);

new animlib[32];
new animname[32];

GetAnimationName(GetPlayerAnimationIndex(playerid) ,animlib,32,animname,32);

sql_CreateActor(actorName, skin, x,y,z,a, animlib, animname);

new string[128];
format(string,sizeof(string), "New actor created. Skin ID: %i Name: %s. Type /reloadactors to reload all actors",skin,actorName);
SendClientMessage(playerid,COLOR_GREY,string);
return 1;
}


Unfortunately it did not work :(

Macronix
12/02/2017, 06:36 PM
Oh sorry, try my code again. I edited my post. ^^

monisoft
12/02/2017, 06:45 PM
Oh sorry, try my code again. I edited my post. ^^

I'm sorry it did not work again
When the ID and enter your name I will again repeat orders and do not.

GoldenLion
12/02/2017, 06:51 PM
Change
if (sscanf(cmd[13],"is[24]",skin,actorName)) return SendClientMessage(playerid,COLOR_GREY,"Usage: /createactor [skinid] [name]");
to
if (sscanf(cmdtext[13],"is[24]",skin,actorName)) return SendClientMessage(playerid,COLOR_GREY,"Usage: /createactor [skinid] [name]");
because "cmd" is just the "/createactor" part so you can't get that stuff from it, but "cmdtext" is the whole command.

Macronix
12/02/2017, 06:57 PM
Yup, he is right. Forgot to add the "text" after cmd. This should definitely work.

I tried to reproduce your command with "cmdtext[13]" and it seems to work for me. :)

monisoft
12/02/2017, 07:00 PM
Change
if (sscanf(cmd[13],"is[24]",skin,actorName)) return SendClientMessage(playerid,COLOR_GREY,"Usage: /createactor [skinid] [name]");
to
if (sscanf(cmdtext[13],"is[24]",skin,actorName)) return SendClientMessage(playerid,COLOR_GREY,"Usage: /createactor [skinid] [name]");
because "cmd" is just the "/createactor" part so you can't get that stuff from it, but "cmdtext" is the whole command.

Whether he was wrong again
This time the error was:
SERVER: Unknow command

GoldenLion
12/02/2017, 07:03 PM
Just show the whole OnPlayerCommandText. Exclude all other commands though if you have any.

monisoft
12/02/2017, 07:15 PM
Just show the whole OnPlayerCommandText. Exclude all other commands though if you have any.

enum aDATA {
aID,
ValidActor,
aName[24],
ActorSkin,
Float:aX,
Float:aY,
Float:aZ,
Float:aA,
Text3D:ActorText,
ActorPlayer,
Actor_AnimLib[30],
Actor_AnimName[30]
};
new ActorData[MAX_ACTORS][aDATA];

CMD:createactor(playerid,params[]) {
new actorName[24],skin;
if(sscanf(params,"is[24]",skin,actorName)) return SendClientMessage(playerid,COLOR_GREY,"Usage: /createactor [skinid] [name] ");
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);

new animlib[32];
new animname[32];

GetAnimationName(GetPlayerAnimationIndex(playerid) ,animlib,32,animname,32);

sql_CreateActor(actorName, skin, x,y,z,a, animlib, animname);

new string[128];
format(string,sizeof(string), "New actor created. Skin ID: %i Name: %s. Type /reloadactors to reload all actors",skin,actorName);
SendClientMessage(playerid,COLOR_GREY,string);
return true;
}

sql_CreateActor(name[]="N/A", skin, Float:x, Float:y,Float:z,Float:a,lib[],libname[]) {
new query[256];
mysql_format(mysql,query,sizeof(query),"INSERT INTO `actors` (`Name`,`SkinID`,`X`,`Y`,`Z`,`A`,`anim_lib`,`anim_ name`) VALUES ('%e',%i,%f,%f,%f,%f,'%e','%e')",name,skin,x,y,z,a,lib,libname);
mysql_tquery(mysql,query,"","");
}



The total orders

sKenzi1996
12/02/2017, 07:29 PM
#Didn't read the latest reply! Sorry.

GoldenLion
12/02/2017, 07:33 PM
enum aDATA {
aID,
ValidActor,
aName[24],
ActorSkin,
Float:aX,
Float:aY,
Float:aZ,
Float:aA,
Text3D:ActorText,
ActorPlayer,
Actor_AnimLib[30],
Actor_AnimName[30]
};
new ActorData[MAX_ACTORS][aDATA];

CMD:createactor(playerid,params[]) {
new actorName[24],skin;
if(sscanf(params,"is[24]",skin,actorName)) return SendClientMessage(playerid,COLOR_GREY,"Usage: /createactor [skinid] [name] ");
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);

new animlib[32];
new animname[32];

GetAnimationName(GetPlayerAnimationIndex(playerid) ,animlib,32,animname,32);

sql_CreateActor(actorName, skin, x,y,z,a, animlib, animname);

new string[128];
format(string,sizeof(string), "New actor created. Skin ID: %i Name: %s. Type /reloadactors to reload all actors",skin,actorName);
SendClientMessage(playerid,COLOR_GREY,string);
return true;
}

sql_CreateActor(name[]="N/A", skin, Float:x, Float:y,Float:z,Float:a,lib[],libname[]) {
new query[256];
mysql_format(mysql,query,sizeof(query),"INSERT INTO `actors` (`Name`,`SkinID`,`X`,`Y`,`Z`,`A`,`anim_lib`,`anim_ name`) VALUES ('%e',%i,%f,%f,%f,%f,'%e','%e')",name,skin,x,y,z,a,lib,libname);
mysql_tquery(mysql,query,"","");
}



The total orders
OnPlayerCommandText.

monisoft
12/02/2017, 07:46 PM
OnPlayerCommandText.

you mean that?

if(strcmp(cmd, "/createactor", true) == 0)
{
new actorName[24],skin;
if (sscanf(cmdtext[13],"is[24]",skin,actorName)) return SendClientMessage(playerid,COLOR_GREY,"Usage: /createactor [skinid] [name]");
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);

new animlib[32];
new animname[32];

GetAnimationName(GetPlayerAnimationIndex(playerid) ,animlib,32,animname,32);

sql_CreateActor(actorName, skin, x,y,z,a, animlib, animname);

new string[128];
format(string,sizeof(string), "New actor created. Skin ID: %i Name: %s. Type /reloadactors to reload all actors",skin,actorName);
SendClientMessage(playerid,COLOR_GREY,string);
return 1;
}

GoldenLion
12/02/2017, 08:15 PM
you mean that?

if(strcmp(cmd, "/createactor", true) == 0)
{
new actorName[24],skin;
if (sscanf(cmdtext[13],"is[24]",skin,actorName)) return SendClientMessage(playerid,COLOR_GREY,"Usage: /createactor [skinid] [name]");
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);

new animlib[32];
new animname[32];

GetAnimationName(GetPlayerAnimationIndex(playerid) ,animlib,32,animname,32);

sql_CreateActor(actorName, skin, x,y,z,a, animlib, animname);

new string[128];
format(string,sizeof(string), "New actor created. Skin ID: %i Name: %s. Type /reloadactors to reload all actors",skin,actorName);
SendClientMessage(playerid,COLOR_GREY,string);
return 1;
}
I mean the whole callback.

monisoft
12/02/2017, 08:27 PM
I mean the whole callback.

I'm sorry I do not understand what you mean Beginners

GoldenLion
12/02/2017, 08:30 PM
I'm sorry I do not understand what you mean Beginners
Now I wonder where did you even put the command with strcmp lol.
http://wiki.sa-mp.com/wiki/OnPlayerCommandText

monisoft
12/02/2017, 08:38 PM
Now I wonder where did you even put the command with strcmp lol.
http://wiki.sa-mp.com/wiki/OnPlayerCommandText

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/reloadactors", cmdtext, true, 10) == 0)
{
sql_LoadAllActors();
return 1;
}
if(strcmp(cmd, "/createactor", true) == 0)
{
new actorName[24],skin;
if (sscanf(cmdtext[13],"is[24]",skin,actorName)) return SendClientMessage(playerid,COLOR_GREY,"Usage: /createactor [skinid] [name]");
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);

new animlib[32];
new animname[32];

GetAnimationName(GetPlayerAnimationIndex(playerid) ,animlib,32,animname,32);

sql_CreateActor(actorName, skin, x,y,z,a, animlib, animname);

new string[128];
format(string,sizeof(string), "New actor created. Skin ID: %i Name: %s. Type /reloadactors to reload all actors",skin,actorName);
SendClientMessage(playerid,COLOR_GREY,string);
return 1;
}
SendClientMessage(playerid, COLOR_YELLOW2, "SERVER: Unknow command!");
return 1;
}


I hope you mean is.

felipegomez
12/02/2017, 10:16 PM
zcmd baby , is very easy command(createactor,playerid,param[]){
action here..
return 1;
}
Just for my welcome in the forum ..

monisoft
13/02/2017, 12:31 PM
plz help me just convert.This is important to me.

monisoft
13/02/2017, 01:22 PM
But I changed my code to this number to zero skin and are not stored in the database, what's the problem?

if(strcmp(cmd, "/createactor", true) == 0)
{
//new actorName[24],skin;
tmp = strtok(cmdtext,idx);
if (!strlen(tmp)) return SendClientMessage(playerid,COLOR_GREY,"Usage: /createactor [skinid] [name]");
new skin;
tmp = strtok(cmdtext, idx);
skin = strval(tmp);
if (!strlen(tmp)) return SendClientMessage(playerid,COLOR_GREY,"Usage: /createactor [skinid] [name]");
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);

new animlib[32];
new animname[32];

GetAnimationName(GetPlayerAnimationIndex(playerid) ,animlib,32,animname,32);

sql_CreateActor(tmp, skin, x,y,z,a, animlib, animname);

new string[128];
format(string,sizeof(string), "New actor created. Skin ID: %i Name: %s. Type /reloadactors to reload all actors",skin,tmp);
SendClientMessage(playerid,COLOR_GREY,string);
return 1;
}