CMD:telep(M, params[]) { new idx; new xyz[256]; xyz = strtok(params, idx); if(isnull(params)) { Kiri(M, RED, "Hint: /telep [x,y,z]"); return 1; } if(User[M][Admin] < 1338) { Kiri(M,RED,"You dont have enough permissions!"); return 1; } Kiri(M,WHITE,"* Teleported"); SetPlayerPos(M, xyz); return 1; }
One problem, I dont want to use sscanf, so how can i make transform into normal?
|
new xyz;
new Float:x, Float:y, Float:z;
SetPlayerPos(playerid, x, y, z);
CMD:telep(M, params[])
{
new idx;
new Float:x, Float:y, Float:z;
if(isnull(params))
{
Kiri(M, RED, "Hint: /telep [x,y,z]");
return 1;
}
if(User[M][Admin] < 1338)
{
Kiri(M,RED,"You dont have enough permissions!");
return 1;
}
SetPlayerPos(M, X, Y, Z);
Kiri(M,WHITE,"* Teleported");
return 1;
}
I'm an old school scripter, so i like that everything is writen out and Don't i want everything to be so easy.
|
CMD:telep(playerid,params[]) { new idx,tmp[128]; if(isnull(params)) { return SendClientMessage(playerid,0xFFFFFFFF,"Hint: /telep x y z"); } if(User[M][Admin] < 1338) {return SendClientMessage(playerid,0xFFFFFFFF,"You dont have enough permissions!");} new Float:X,Float:Y,Float:Z; strtok(tmp,idx); X = floatstr(tmp); strtok(tmp,idx); Y = floatstr(tmp); strtok(tmp,idx); Z = floatstr(tmp); SetPlayerPos(playerid,X,Y,Z); return 1; }
CMD:telep(playerid,params[]) { new Float:X,Float:Y,Float:Z; if(sscanf(params,"fff",X,Y,Z) { SendClientMessage(playerid,0xFFFFFFFF,"Hint: /telep x y z"); } else { if(User[M][Admin] < 1338) {return SendClientMessage(playerid,0xFFFFFFFF,"You dont have enough permissions!");} SetPlayerPos(playerid,X,Y,Z); } return 1; }
if(!strcmp("/gotopoint",cmdtext,true))
{
new
Float:x,
Float:y,
Float:z;
if(sscanf(params,"fff",x,y,z))
{
return SendClientMessage(playerid,-1,"USAGE: /gotopoint <x> <y> <z>");
}
else
{
new string[128];
format(string,sizeof(string),"You have teleported to coordinates: X:%f Y:%f Z:%f",x,y,z);
SendClientMessage(playerid,-1,string);
SetPlayerPos(playerid,x,y,z);
return 1;
}
}
There is nothing wrong with using more practical methods like sscanf to get what you want. It wastes time, and mistakes are easy to be made. I posted this mainly because the code above me is incorrect.
pawn Код:
|
if(!strcmp("/gotopoint",cmdtext,true))
{
new Float:x,Float:y,Float:z,string[128];
if(sscanf(params,"fff",x,y,z)) return SendClientMessage(playerid,-1,"USAGE: /gotopoint <x> <y> <z>");
format(string,sizeof(string),"You have teleported to coordinates: X:%f Y:%f Z:%f",x,y,z);
SendClientMessage(playerid,-1,string);
SetPlayerPos(playerid,x,y,z);
return 1;
}