Posts: 754
Threads: 42
Joined: Jan 2008
Hey!
Don't know if this is the right section or If I have the permission to create my own topic here.. but anyway..
I need some help with creating /kill command and would be super if I could get help with creating a command /teleport command, similar to the teleport system on LVP. Like /tp 8 and I spawn on the player with the id 8.
I'm currently making a 16 slot freeroam server.
Thank you!
|
Posts: 751
Threads: 74
Joined: Jan 2008
05-05-2008, 08:24 AM
(This post was last modified: 05-05-2008, 08:32 AM by AzTeC)
Code: if(strcmp(cmdtext, "/kill", true) == 0)
{
SetPlayerHealth(playerid,0.0);
return 1;
}
put this at the OnPlayercommandtext
my teleport system has some bugs so i'm not posting it till i fix it
|
Posts: 6,609
Threads: 788
Joined: Dec 2006
Code: if(strcmp(cmdtext, "/kill", true) == 0) return SetPlayerHealth(playerid,0);
I suggest making a teleport script using dcmd and sscanf, as they are the easiest functions when it comes down to it. More information can be found here.
Code: dcmd_teleport(playerid,params[])
{
new endid;
if(sscanf(params, "d",endid)) return SendClientMessage(playerid,white,"Correct Usage: /teleport <playerid>");
if(!IsPlayerConnected(endid)) return SendClientMessage(playerid,COLOR_RED,"Invalid player id.");
if(playerid == endid) return SendClientMessage(playerid,red,"You can't teleport to yourself!");
new Float:Pos[3];
GetPlayerPos(endid,Pos[0],Pos[1],Pos[2]);
SetPlayerPos(playerid,Pos[0]+1,Pos[1],Pos[2]);
SetPlayerInterior(playerid,(GetPlayerInterior(endid)));
return true;
}
|
Posts: 754
Threads: 42
Joined: Jan 2008
oh! I never belived that you guys accutally would help me ! Thank you!!!
|
Posts: 754
Threads: 42
Joined: Jan 2008
ok so I've added the text you gave me..
But!
I now recive warnings
(374) : warning 209: function "OnPlayerCommandText" should return a value
(69 : warning 203: symbol is never used: "dcmd_teleport"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
Please help me out.
|
Posts: 61
Threads: 9
Joined: Feb 2008
post your code
|
Posts: 754
Threads: 42
Joined: Jan 2008
Quote://my includes
#include <a_samp>
#include <core>
#include <float>
#include <string.inc>
//my defines
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_PINK 0xFF66FFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_DARKRED 0x660000AA
#define COLOR_ORANGE 0xFF9900AA
The Part that don't want to work out.
//------------------------------------------------------------------------------
//public OnPlayerText(playerid, text[])
//{
// if (strcmp(text, "armour", true) == 0)
// {
// new Float:armour, string[70];
// GetPlayerArmour(playerid, armour);
// format(string, sizeof(string), "Console: You armour is %d", armour);
// SendClientMessage(playerid, 0xFFFFFFAA, string);
// return 0;
// }
// return 1;
//}
//------------------------------------------------------------------------------
public OnPlayerCommandText(playerid, cmdtext[])
//{
//if(strcmp(cmdtext, "/kill", true) == 0) return SetPlayerHealth(playerid,0);
//}
//dcmd_teleport(playerid,params[])
//{
// new endid;
// if(sscanf(params, "d",endid)) return SendClientMessage(playerid,white,"Correct Usage: /teleport <playerid>");
// if(!IsPlayerConnected(endid)) return SendClientMessage(playerid,COLOR_RED,"Invalid player id.");
// if(playerid == endid) return SendClientMessage(playerid,red,"You can't teleport to yourself!");
// new Floatos[3];
// GetPlayerPos(endid,Pos[0],Pos[1],Pos[2]);
// SetPlayerPos(playerid,Pos[0]+1,Pos[1],Pos[2]);
// SetPlayerInterior(playerid,(GetPlayerInterior(endid)));
// return true;
//new WaitDelay[MAX_PLAYERS],
// String[32];
//{
// if (!strcmp(cmdtext,"/teleport <playerid>"))
// {
// new waittime = gettime() - WaitDelay[playerid];
// if (waittime < 5)
// {
// format(String, sizeof(String), "You need to wait %d seconds!", 5 - waittime);
// SendClientMessage(playerid, 0xFF0000FF, String);
// }
//else
// {
// SendClientMessage(playerid, 0x00FF00FF, "Ok!");
// WaitDelay[playerid] = gettime();
// }
// return true;
// }
// return false;
//}
//-------------------------------------------------------------------
//Team Defines
just igonre the "//"
Ant this is not the whole script as you can se...
*help*
Would be super duper nice if someone could help me out with a car respawn command to!
|
Posts: 6,609
Threads: 788
Joined: Dec 2006
Do what it says.
OnPlayerCommandText should return 0. And you need to learn dcmd...
|
Posts: 61
Threads: 9
Joined: Feb 2008
Let me help you ,
First, You must define your dcmd command, underneeth OnPlayerCommandText.
So it looks like this:
Code: OnPlayerCommandText(playerid, cmdtext[]) {
dcmd(teleport,8,cmdtext);
return 0;
}
Okay, let me explain the Dcmd thing.
First, you typ the name of the command that you want to use, in this case teleport
dcmd( teleport,8,cmdtext);
Then the system must knows how many charackters the are in the command, in teleport is that 8
dcmd(teleport, 8,cmdtext);
and after that you type cmdtext, to let know that it is a cmd(not for sure!!).
dcmd(teleport,8, cmdtext);
Okay you have made your define.
You dont put you dcmd command into the OnPlayerCommandText thing, it will give errors.
But past it underneeth it, like this:
Code: OnPlayerCommandText(playerid, cmdtext[]) {
dcmd(teleport,8,cmdtext);
return 0;
}
dcmd_teleport(playerid,params[])
{
new endid;
if(sscanf(params, "d",endid)) return SendClientMessage(playerid,white,"Correct Usage: /teleport <playerid>");
if(!IsPlayerConnected(endid)) return SendClientMessage(playerid,COLOR_RED,"Invalid player id.");
if(playerid == endid) return SendClientMessage(playerid,red,"You can't teleport to yourself!");
new Float:Pos[3];
GetPlayerPos(endid,Pos[0],Pos[1],Pos[2]);
SetPlayerPos(playerid,Pos[0]+1,Pos[1],Pos[2]);
SetPlayerInterior(playerid,(GetPlayerInterior(endid)));
return 1;
}
Now you have a working dcmd command.
Good luck whit it
If there is anything wrong in this post, post it please.
It is also new for me
Grtz Dimplex
|
Posts: 754
Threads: 42
Joined: Jan 2008
I don't know how to thank you, just one question, don't I have to add like a "#define cmdtext" or "include dcmd" thing?
I'm gonna try to use what you gave me now, maybe it turns out I don't have to add a define/include text only for the teleport...
OH and whats the color id of the car with the text "C1" ?
|
|