/goto, /get, /getthere -
Markx - 19.03.2011
Hey all!
I tryd to make some commands like /goto [ID], /get [ID], /getthere [x] [y] [z].. But i just made a epic fail xD can someone show me how to make it on Zcmd
Re: /goto, /get, /getthere -
Biesmen - 19.03.2011
Do you use
sscanf or strtok?
Re: /goto, /get, /getthere -
Markx - 19.03.2011
sscanf
Re: /goto, /get, /getthere -
PinkFloydLover - 19.03.2011
pawn Код:
new id, Float:x, Float:y, Float:z;
GetPlayerPos(playerid,x,y,z);
if(sscanf(params,"u",id)) return 0;
SetPlayerPos(id,x,y,z);
/getcommand
it's that simple
Re: /goto, /get, /getthere - [L3th4l] - 19.03.2011
pawn Код:
CMD:get(playerid, params[])
{
if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "Usage: /Get < Player ID >"); // Didn't complete the command
new
pID = strval(params),
Float:g_Pos[3]; // Needed to hold the player's position ( The one who used the cmd ), array of 3: x , y , z
if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "User is not connected!"); // Check if the user we are getting is online
GetPlayerPos(playerid, g_Pos[0], g_Pos[1], g_Pos[2]); // Getting the player's position and storing it into our array
SetPlayerPos(pID, g_Pos[0], g_Pos[1], g_Pos[2]); // Setting the player that we selected, 'pID' and setting his position to the player that used the cmd 'playerid'
return 1;
}
pawn Код:
CMD:goto(playerid, params[])
{
if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "Usage: /Get < Player ID >"); // Didn't complete the command
new
pID = strval(params),
Float:g_Pos[3]; // Needed to hold the player's position ( The targeted player ), array of 3: x , y , z
if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "User is not connected!"); // Check if the user we are getting is online
GetPlayerPos(pID, g_Pos[0], g_Pos[1], g_Pos[2]); // Getting our target's position and storing it onto our variables
SetPlayerPos(playerid, g_Pos[0], g_Pos[1], g_Pos[2]); // Setting the player who used the cmd to our target's location
return 1;
}
pawn Код:
CMD:gothere(playerid, params[]) // /GoThere 0.0 0.0 0.0
{
new
Float:g_Pos[3];
if(sscanf(params, "fff", g_Pos[0], g_Pos[1], g_Pos[2])) return SendClientMessage(playerid, COLOR_RED, "Usage: /GoThere < X > < Y > < Z >");
return SetPlayerPos(playerid, g_Pos[0], g_Pos[1], g_Pos[2]);
}
Re: /goto, /get, /getthere -
Pooh7 - 19.03.2011
pawn Код:
CMD:goto(playerid, params[])
{
new id, Float:Pos[3];
if(sscanf(params, "u", id)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /goto [playerid]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFFFFFFFF, "That player is offline!");
GetPlayerPos(id, Pos[0], Pos[1], Pos[2]);
SetPlayerPos(playerid, Pos[0], Pos[1]+4, Pos[2]);
return 1;
}
CMD:get(playerid, params[])
{
new id, Float:Pos[3];
if(sscanf(params, "u", id)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /get [playerid]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFFFFFFFF, "That player is offline!");
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
SetPlayerPos(id, Pos[0], Pos[1]+4, Pos[2]);
return 1;
}
CMD:getthere(playerid, params[])
{
new Float:Pos[3];
if(sscanf(params, "fff", Pos[0], Pos[1], Pos[2])) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /getthere [X] [Y] [Z]");
SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
return 1;
}
Re: /goto, /get, /getthere -
Markx - 19.03.2011
Thanks all! I learned much now ^^
Re: /goto, /get, /getthere -
Markx - 19.03.2011
Im sorry for duble post, but i got this:
pawn Код:
CMD:slap(playerid, params[])
{
new Float:x,Float:y,Float:z;
if(PVar[playerid][pLevel] >= 1)
{
new pID, Msg[128];
if(sscanf(params, "us[60]", pID)) return SendClientMessage(playerid, COLOR_RED, "* Usage: /slap [PlayerID]");
if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "ERROR : That user is not connected!");
if(!IsPlayerConnected(pID) || pID == playerid) return SendClientMessage(playerid, COLOR_RED, "ERROR : Player not connected or its yourself!");
format(Msg, sizeof(Msg), "** Administrator %s has slapped %s!", pName(playerid), pName(pID));
SendClientMessageToAll(COLOR_YELLOW, Msg);
SetPlayerHealth(pID, -20);
GetPlayerPos(pID,x,y,x);
SetPlayerPos(pID,x,y,z+6);
PlayerPlaySound(pID, 1190, x, y, z);
SendClientMessage(pID, COLOR_RED, "You have been slapped! Behave yourself!");
}
else return SendClientMessage(playerid, COLOR_RED, "ERROR : This command is for admin level 1 only!");
return true;
}
CMD:slapall(playerid, params[])
{
new Float:x,Float:y,Float:z;
new Msg[128];
if(PVar[playerid][pLevel] >= 3)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
SetPlayerHealth(i, -20);
GetPlayerPos(i,x,y,x);
SetPlayerPos(i,x,y,z+6);
PlayerPlaySound(i, 1190, x, y, z);
SendClientMessage(i, COLOR_RED, "You have been slapped! Behave yourself!");
}
}
format(Msg, sizeof(Msg), "** Administrator %s has slapped all players!", pName(playerid));
SendClientMessageToAll(COLOR_GREY, Msg);
}
else return SendClientMessage(playerid, COLOR_RED, "ERROR : This command is for admin level 3 only!");
return true;
}
All works, but kills all (it should take some health and put the player a little bit up) how to fix it?
Re: /goto, /get, /getthere -
Biesmen - 19.03.2011
You're setting someone's HP to -20, which is lower than 0, which means you're dead.
Correct usage:
pawn Код:
new Float:hp;
GetPlayerHealth(pID, hp);
SetPlayerHealth(pID, hp -20);
for your /slapall command:
pawn Код:
new Float:hp;
GetPlayerHealth(i, hp);
SetPlayerHealth(i, hp -20);