SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 20/03/2009, 11:31 PM   #1
hazdog
Big Clucker
 
Join Date: Nov 2008
Posts: 77
Reputation: 0
Default /move [x] [y] [z]

hey there....

ive been working with DCMD to get a /move command that allows you to move any place you wish...


there are a few errors, and i'm unsure of how to fix.

Code:
dcmd_move(playerid,params[]) {
	  new tmp[256], tmp2[256], tmp3[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index), tmp3 = strtok(params,Index);
	  if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid, POLICE_COLOR, "USAGE: /move [X] [Y] [Z]");
		new X, Y, Z, string[128];
		return SetPlayerPos(playerid, X, Y, Z);
}

C:\PROGRA~1\GAMES\GTASAN~1\GAMEMO~1\NRGSPAWN.pwn(8 : error 017: undefined symbol "strtok"
C:\PROGRA~1\GAMES\GTASAN~1\GAMEMO~1\NRGSPAWN.pwn(8 : error 033: array must be indexed (variable "tmp3")
C:\PROGRA~1\GAMES\GTASAN~1\GAMEMO~1\NRGSPAWN.pwn(9 0) : warning 204: symbol is assigned a value that is never used: "string"
C:\PROGRA~1\GAMES\GTASAN~1\GAMEMO~1\NRGSPAWN.pwn(8 : warning 203: symbol is never used: "Index"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.


cheers,

hazdog
hazdog is offline  
Old 20/03/2009, 11:34 PM   #2
brett7
Gangsta
 
brett7's Avatar
 
Join Date: Nov 2007
Location: samp is #1
Posts: 669
Reputation: 14
Default Re: /move [x] [y] [z]

it says undefined symbol strtok did you define it right?

pawn Code:
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }
 
    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
brett7 is offline  
Old 20/03/2009, 11:40 PM   #3
ICECOLDKILLAK8
High-roller
 
Join Date: Aug 2008
Posts: 1,154
Reputation: 5
Default Re: /move [x] [y] [z]

Aswell as that use this
pawn Code:
dcmd_move(playerid,params[])
{
  #pragma unused Index
  new tmp[256], tmp2[256], tmp3[256], Index;
  tmp = strtok(params,Index), tmp2 = strtok(params,Index), tmp3 = strtok(params,Index);
  if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid, POLICE_COLOR, "USAGE: /move [X] [Y] [Z]");
  new X, Y, Z;
  return SetPlayerPos(playerid, X, Y, Z);
}
__________________
IVMP
ICECOLDKILLAK8 is offline  
Old 21/03/2009, 02:22 AM   #4
hazdog
Big Clucker
 
Join Date: Nov 2008
Posts: 77
Reputation: 0
Default Re: /move [x] [y] [z]

it gets a perfect compile but just says unknown command in game.
hazdog is offline  
Old 21/03/2009, 02:25 AM   #5
Norn
High-roller
 
Norn's Avatar
 
Join Date: Jul 2008
Location: Northern Ireland
Posts: 2,265
Reputation: 206
Default Re: /move [x] [y] [z]

Quote:
Originally Posted by hazdog
it gets a perfect compile but just says unknown command in game.
You gotta put the dcmd call under OnPlayerCommandText lawl.
__________________
Pursuing other endeavours.

Skype: datinvictusguy
Norn is offline  
Old 21/03/2009, 02:25 AM   #6
hazdog
Big Clucker
 
Join Date: Nov 2008
Posts: 77
Reputation: 0
Default Re: /move [x] [y] [z]

i have...
hazdog is offline  
Old 21/03/2009, 08:53 AM   #7
Donny_k
Gangsta
 
Donny_k's Avatar
 
Join Date: May 2006
Posts: 786
Reputation: 4
Default Re: /move [x] [y] [z]

sscanf method:

pawn Code:
//bottom of script
dcmd_move( playerid, params[] )
{
  new
    Float:x,
    Float:y,
    Float:z;

  if ( sscanf( params, "fff", x, y, z ) ) return SendClientMessage( playerid, POLICE_COLOR, "USAGE: /move [X] [Y] [Z]" );
  SetPlayerPos( playerid, x, y, z );
  return 1;
}

//OnPlayerCommandText
  dcmd(move, 4, cmdtext);

The Wiki page for sscanf.
__________________
We don't stop playing because we grow old, we grow old because we stop playing.
Donny_k is offline  
Old 21/03/2009, 10:55 AM   #8
LarzI
High-roller
 
LarzI's Avatar
 
Join Date: Apr 2007
Location: Norway
Posts: 2,628
Reputation: 136
Default Re: /move [x] [y] [z]

I recommend using Donny's version.
dcmd is made to make commands easier, so is sscanf.
It's kinda strtok's rival, so don't use them together
strcmp & strtok
or
dcmd & sscanf
__________________


NEW: [FS] Simple Cellphones

if( strfind( title, "REP", true ) != -1 )
{________________________________________
Sigh();__________________________
}________________________________________


LarzI is offline  
Old 21/03/2009, 11:02 AM   #9
MenaceX^
High-roller
 
Join Date: Aug 2008
Posts: 3,262
Reputation: 13
Default Re: /move [x] [y] [z]

Quote:
Originally Posted by brett7
it says undefined symbol strtok did you define it right?

pawn Code:
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }
 
    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
pawn Code:
strtok(const string[], &index, separator = ' ')
{
  new length = strlen(string);
  while ((index < length) && (string[index] <= separator))
  {
    index++;
  }
  new offset = index;
  new result[20];
  while ((index < length) && (string[index] > separator) && ((index - offset) < (sizeof(result) - 1)))
  {
    result[index - offset] = string[index];
    index++;
  }
  result[index - offset] = EOS;
  return result;
}
MenaceX^ is offline  
 

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
Can't see each other move ihatetn931 Help Archive 5 12/03/2010 10:57 AM
move object Brian_Furios Help Archive 1 11/03/2010 07:59 PM
Bot not move whitedragon Help Archive 7 23/01/2010 01:11 PM
NPC doesn't move:S Nomis3 Help Archive 3 10/10/2009 07:18 PM
I like to move it move it, I like to move it move it xD Dujma Everything and Nothing 4 18/12/2008 08:49 AM


All times are GMT. The time now is 12:48 PM.


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