ZCMD problems -
lukas567 - 19.03.2012
Hello.
First problem:
Code:
CMD:get(playerid, params[])
{
if(sscanf(params, "u", player))
{
ShadInfoBoxForPlayer(playerid, "/get [who?]");
return 1;
}
if(IsPlayerConnected(player))
{
ShadInfoBoxForPlayer(playerid, "Player isnt online");
return 1;
}
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
SetPlayerPos(player, x, y, z);
return 1;
}
Player Name: Lussy_More
Command typed: /get lus
Returned: Player isnt online.
Second problem:
Code:
CMD:toall(playerid, params[])
{
if(sscanf(params, "c[50]", text))
{
ShadInfoBoxForPlayer(playerid, "/toall [text]");
return 1;
}
SendClientMessageToAll(RED, text);
return 1;
}
Typed command: /toall hello!
Returned: h
Thanks!
Re: ZCMD problems -
emokidx - 19.03.2012
pawn Code:
if(!IsPlayerConnected(player))
the code you have will return that for every player that is online. use this
pawn Code:
if(sscanf(params, "s[50]", text))
use the "s" parameter for this
Re: ZCMD problems -
.:Kaos:. - 19.03.2012
Code:
if(IsPlayerConnected(player))
{
ShadInfoBoxForPlayer(playerid, "Player isnt online");
return 1;
}
Needs to be,
Code:
if(!IsPlayerConnected(player))
{
ShadInfoBoxForPlayer(playerid, "Player isnt online");
return 1;
}
#Edit; Beat me to it.
Re: ZCMD problems -
!LukniS! - 19.03.2012
Code:
CMD:toall(playerid, params[])
{
new text[50];
if(sscanf(params, "s[50]", text))
{
ShadInfoBoxForPlayer(playerid, "/toall [text]");
return 1;
}
SendClientMessageToAll(RED, text);
return 1;
}
Command: /toall wtf
Returned: /toall [text]
Code:
CMD:npc(playerid, params[])
{
new file[20];
if(sscanf(params, "c[20]", file))
{
SendClientMessage(playerid, RED, "/npc [name]");
return 1;
}
if(!IsPlayerInAnyVehicle(playerid))
{
StartRecordingPlayerData(playerid,PLAYER_RECORDING_TYPE_ONFOOT,file);
SendClientMessage(playerid,GREEN,"Started");
return 1;
}
StartRecordingPlayerData(playerid,PLAYER_RECORDING_TYPE_DRIVER,file);
SendClientMessage(playerid,GREEN,"Started");
return 1;
}
Command: /npc teacher
Returned: /npc [name]
Re: ZCMD problems -
Babul - 19.03.2012
each ZCMD is a callback, so you need to declare each variable for usage, in this case, the TargetID:
pawn Code:
CMD:get(playerid, params[])
{
new TargetID
if(sscanf(params, "u", TargetID))
{
ShadInfoBoxForPlayer(playerid, "/get [playerid/name]");
return 1;
}
if(!IsPlayerConnected(TargetID))
{
ShadInfoBoxForPlayer(playerid, "Player isnt online");
return 1;
}
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
SetPlayerPos(TargetID, x+1, y+1, z);
return 1;
}
its a good idea to spawn the other player at a slightly different coordinate. north east, 1 meter each, is fine i hope.
the next step would ne checking if the TargetID is in any vehicle, and depending on being in a vehicle or not, get the TargetID or the vehicle the TargetID sits in..
the "c" specifier is a charcter. you need a "s" string:
pawn Code:
CMD:toall(playerid, params[])
{
new text[50]
if(sscanf(params, "s[50]", text))
{
ShadInfoBoxForPlayer(playerid, "/toall [text]");
return 1;
}
SendClientMessageToAll(RED, text);
return 1;
}