SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 19/03/2012, 11:25 AM   #1
lukas567
Big Clucker
 
Join Date: Jun 2011
Posts: 152
Reputation: 0
Default ZCMD problems

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!
lukas567 is offline   Reply With Quote
Old 19/03/2012, 11:28 AM   #2
emokidx
Gangsta
 
emokidx's Avatar
 
Join Date: Jul 2011
Posts: 550
Reputation: 63
Default Re: ZCMD problems

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
emokidx is offline   Reply With Quote
Old 19/03/2012, 11:28 AM   #3
.:Kaos:.
Big Clucker
 
.:Kaos:.'s Avatar
 
Join Date: Sep 2011
Posts: 72
Reputation: 9
Default Re: ZCMD problems

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.
.:Kaos:. is offline   Reply With Quote
Old 19/03/2012, 11:59 AM   #4
!LukniS!
Little Clucker
 
Join Date: Dec 2011
Posts: 25
Reputation: 4
Default Re: ZCMD problems

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]
!LukniS! is offline   Reply With Quote
Old 19/03/2012, 12:34 PM   #5
Babul
High-roller
 
Babul's Avatar
 
Join Date: Sep 2009
Location: in a cement block
Posts: 1,781
Reputation: 266
Default Re: ZCMD problems

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;
}
__________________
FireWorks

new sscanf2 custom specifiers available for Download, read the Release Topic
Babul is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tutorial] STRCMP and ZCMD - how to change your commands to ZCMD Swyft Tutorials 12 14/01/2015 09:58 PM
Problems with making a command. ZCMD rooney12 Scripting Help 5 15/12/2011 05:53 PM
ZCMD Problems KingstoN* Help Archive 5 26/08/2010 01:23 AM
zcmd problems ScottCFR Help Archive 9 20/08/2010 01:44 AM
[FS]CarOwnership problems, GM Problems coole210 Help Archive 8 17/06/2009 09:27 PM


All times are GMT. The time now is 06:02 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.