enterh or exith cmd

Started by Amazing, Dec 28, 2015, 11:18 PM

Previous topic - Next topic

Amazing

Hello Guys i need one help please anyone give me a cmd of enterh or exith.i hope anyone help me!

Murdock

function onPlayerCommand( player, command, args )
{
  if ( command == "enterh" )
  {
    // Your functionality
  }
 
  if ( command == "exith" )
  {
    // Your functionality
  }
}

There you go!

Williams

It's easy to make.

else if ( cmd  == "enterh" )
{
if ( IsNoob( player, cmd ) ) return 0;
else if ( !text ) MessagePlayer(WHITE+"Usage: /"+cmd+" [ID]", player );
else {
switch( text.tolower() )
{
case "1":
player.Pos = Vector ( -944.2378,-343.7493,7.2269 )
MessagePlayer(MSG+"You've enter in house.", player );
break;
}
}
}


else if ( cmd == "exith" )
{
if ( IsNoob( player, cmd ) ) return 0;
else if ( !text ) MessagePlayer(WHITE+"Usage: /"+cmd+" [ID]", player );
else {
switch( text.tolower() )
{
case "1":
player.Pos = Vector ( -1074.912964, -276.7081299, 11.05003262 )
MessagePlayer(MSG+"You've exit from house.", player );
break;
}
}
}

Only you want to add that player is near to house..
Hey, i m always at IRC and Forum you can comtact me at IRC channel :- #GDM @LUNet and Forum :- http://pro-fighter.tk/index.php

Karthik

William good
off topic william see my pm plz u havent given

KAKAN

You can actually query from a database, which would be better else you would need to update it every time you do something.
An example of it:-
function onScriptLoad(){
db<- ConnectSQL("Jaja.db");
QuerySQL(db,"CREATE TABLE IF NOT EXISTS House( Name TEXT, InPos TEXT, OutPos TEXT )");
}

function onPlayerCommand(player,cmd,text){
if( cmd ==  "enterh" ){
if(!text) PrivMessage(player,"JAJAJAJAJAJ");
else if(!IsNum(text)) PrivMessage(player,"HAHAHAHAHAH");
else{
local q = QuerySQL(db,"SELECT Name, InPos FROM House WHERE Name='"+text.tointeger()+"'");
if( !GetSQLColumnData(q,0) ) PrivMessage(player,"FACK OFF, WRONG ONE! TRY AGAIN NUB!" );
else player.Pos = GetSQLColumnData(q,1);
FreeSQLQuery(q)
}
}
}
Make the other cmds yourself
oh no

Amazing


Thijn

@KAKAN
player.Pos = GetSQLColumnData(q,1);
How do you expect this to work?

KAKAN

local q = QuerySQL(db,"SELECT Name, InPos FROM House WHERE Name='"+text.tointeger()+"'");Because I select Name, InPos.
That was just an example for him to see.
oh no

Anik

If you are trying to make like CRAST's one it will take a lot of time.

Thijn

Quote from: KAKAN on Dec 29, 2015, 01:21 PMlocal q = QuerySQL(db,"SELECT Name, InPos FROM House WHERE Name='"+text.tointeger()+"'");Because I select Name, InPos.
That was just an example for him to see.
That's not what I mean. player.Pos needs a vector, not a string.

KAKAN

Quote from: Thijn on Dec 29, 2015, 02:45 PM
Quote from: KAKAN on Dec 29, 2015, 01:21 PMlocal q = QuerySQL(db,"SELECT Name, InPos FROM House WHERE Name='"+text.tointeger()+"'");Because I select Name, InPos.
That was just an example for him to see.
That's not what I mean. player.Pos needs a vector, not a string.
Look, I saved all the things in one column named InPos. So it must be Vector :D
oh no

Thijn

Quote from: KAKAN on Dec 29, 2015, 05:00 PM
Quote from: Thijn on Dec 29, 2015, 02:45 PM
Quote from: KAKAN on Dec 29, 2015, 01:21 PMlocal q = QuerySQL(db,"SELECT Name, InPos FROM House WHERE Name='"+text.tointeger()+"'");Because I select Name, InPos.
That was just an example for him to see.
That's not what I mean. player.Pos needs a vector, not a string.
Look, I saved all the things in one column named InPos. So it must be Vector :D
That's not a vector, that's a string.
Try executing this code and watch your server crash:
local testPos = "123.0 123.0 123.0";
player.Pos = testPos;

KAKAN

Hmm, yeah, thanks for that!
But, why can't we save a Vector as a string?
oh no

DizzasTeR

#13
Quote from: KAKAN on Dec 29, 2015, 06:25 PMHmm, yeah, thanks for that!
But, why can't we save a Vector as a string?

That's why we have .tointeger() / .tofloat( ) smarty.