AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need help with my first script (https://forums.alliedmods.net/showthread.php?t=28012)

kuidao 05-05-2006 03:01

Need help with my first script
 
Hi everybody, It's my first script, so don't call me n00b (I'm a n00b, as you can see, but don't tell me)

Code:
--------------------------------------------------------------------------------- /* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <dbi> #include <tsx> #include <engine> #include <engine_stocks> #include <fun> #include <tsxaddon> #define PLUGIN "Matrix Phone" #define VERSION "1.0" #define AUTHOR "Kuidao Ketemeto" public plugin_init() {     register_plugin("Matrix Phone", "1.0", "Kuidao Ketemeto")         register_srvcmd("item_mphone","item_mphone")         // Add your code here... } // Precaching some stuff public plugin_precache() {     precache_sound("items/kuidao/teleport.wav") } //////////////////////////////////// //      ITEM /////////////////////////////////// // The Matrix Phone public item_mphone(id) {   new origin[3]   new authid[32]         get_user_authid(id,authid,31)     get_user_origin(id,origin)     origin[0] = -326 // X coordinates     origin[1] = 152 // Y coordinates     origin[2] = -25 // Z coordinates     set_user_origin(id,origin)   // Moves the player to the location stored in origin     client_cmd(id,"speak ^"items/kuidao/teleport^"")     return PLUGIN_HANDLED } -----------------------------------------------------------------------------------

When I compile it, I have 2 warnings in files 41 and 47...

It's a TSRP plugin, workin with Harbu's.
When I use that item in the server, it plays the sound, but doesn't teleport me, in the server console I can see this:

-----------------------------------------------
L 05/05/2006 - 07:56:22: [AMXX] Native error in "get_user_origin" on line 42 (file "matrix_phone.sma").
-----------------------------------------------

Please help me


(I'm Spanish, sorry my english)

p3tsin 05-05-2006 06:35

u registered "item_mphone" as a servercommand, so there won't be an id passed into the function (it will be 0)
use register_clcmd instead :)

(btw, engine_stocks.inc is already included in engine.inc)

wonsae 05-05-2006 08:51

You don't need all those included and to the person above me it's for tsrp i'm guessing so he needs to use server command

kuidao 05-05-2006 09:26

[small]
---------------------------------------------------------------------------------
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <dbi>
#include <tsx>
#include <engine>
#include <engine_stocks>
#include <fun>
#include <tsxaddon>

#define PLUGIN "Matrix Phone"
#define VERSION "1.0"
#define AUTHOR "Kuidao Ketemeto"


public plugin_init() {
register_plugin("Matrix Phone", "1.0", "Kuidao Ketemeto")

register_clcmd("item_mphone","item_mphone")

// Add your code here...
}

// Precaching some stuff
public plugin_precache()
{
precache_sound("items/kuidao/teleport.wav")
}

////////////////////////////////////
// ITEM
///////////////////////////////////

// The Matrix Phone
public item_mphone(id)
{
new origin[3]
new authid[32]

get_user_authid(id,authid,31)
get_user_origin(id,origin)
origin[0] = -326 // X coordinates
origin[1] = 152 // Y coordinates
origin[2] = -25 // Z coordinates
set_user_origin(id,origin) // Moves the player to the location stored in origin
client_cmd(id,"speak ^"items/kuidao/teleport^"")
return PLUGIN_HANDLED
}
-----------------------------------------------------------------------------------
[small]

but now it's no working, the warnings are the same, but now is not working

Rixorster 05-05-2006 09:42

Hmm, maybe, try to put this in the top(after #define's)
Code:
new Float:porigin[3] = { -326.0, 152.0, -25.0 }
And then:
Code:
set_user_origin(id,porigin)
Lemme write the full code <.<
Edit:Here:
Code:
// Edited by Rixorster #include <amxmodx> #include <amxmisc> #include <engine> #include <fun> new Float:porigin[3] = { -326.0, 152.0, -25.0 } public plugin_init() {     register_plugin("Matrix Phone", "1.0", "Kuidao Ketemeto")         register_clcmd("item_mphone","item_mphone")         // Add your code here... } // Precaching some stuff public plugin_precache() {     precache_sound("items/kuidao/teleport.wav") } //////////////////////////////////// //        ITEM /////////////////////////////////// // The Matrix Phone public item_mphone(id) {   new origin[3]   new authid[32]         get_user_authid(id,authid,31)     get_user_origin(id,origin)     set_user_origin(id,porigin)   // Moves the player to the location stored in origin     client_cmd(id,"speak ^"items/kuidao/teleport^"")     return PLUGIN_HANDLED } -----------------------------------------------------------------------------------
Untested, but should work.
Edit: Fixage, forgot one thing <.<
Edit:Fixed

kuidao 05-05-2006 10:11

no
 
It doesn't work anyway...

Now the warnings are:

<34> : warning 217: loose identation

and

<37> : warning 213: tag mismatch

And now it's no workin, NOTHING, no errors in server console...


// EDIT:

I wrote register_srvcmd again, and it plays the sound and I get this error in console:

[AMXX] Native error in "get_user_origin" on line 36 (file "matrix_phone.sma").

Rixorster 05-05-2006 12:18

Yep, i know that, i get it around many scripts, got no idea what it means but doesn't matter for me :P
Anyways, this should work fine.
Code:
// Edited by Rixorster #include <amxmodx> #include <amxmisc> #include <engine> #include <fun> #include <fakemeta> new Float:porigin[3] = { -326.0, 152.0, -25.0 } public plugin_init() {     register_plugin("Matrix Phone", "1.0", "Kuidao Ketemeto")     register_clcmd("item_mphone","item_mphone") } // Precaching some stuff public plugin_precache() {     precache_sound("items/kuidao/teleport.wav") } //////////////////////////////////// //        ITEM /////////////////////////////////// // The Matrix Phone public item_mphone(id) {     new Origin[3]     get_user_origin(id,Origin)     new authid[32]     get_user_authid(id,authid,31)     set_user_origin(id,porigin)   // Moves the player to the location stored in origin     client_cmd(id,"speak ^"items/kuidao/teleport^"")     return PLUGIN_HANDLED }
But i don't get one thing, why you have that authid thing there? <.<

kuidao 05-05-2006 13:39

well, I don't know, but look:

[AMXX] Native error in "get_user_origin" on line 30 (file "matrix_phone.sma").

But now I have only 1 warning!

<33> : warning 213: tag mismatch

kuidao 05-05-2006 14:07

[small]
----------------------------------------------------------------
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
#include <fakemeta>

new porigin[3] = { -326, 152, -25 }


public plugin_init() {
register_plugin("Matrix Phone", "1.0", "Kuidao Ketemeto")
register_clcmd("item_mphone","item_mphone")
}

// Precaching some stuff
public plugin_precache()
{
precache_sound("items/kuidao/teleport.wav")
}

////////////////////////////////////
// ITEM
///////////////////////////////////

// The Matrix Phone
public item_mphone(id)
{
set_user_origin(id, porigin) // Moves the player to the location stored in origin
client_cmd(id,"speak ^"items/kuidao/teleport^"")
return PLUGIN_HANDLED
}
----------------------------------------------
[small]

ok, Sean D told me to do this, well, thanks, no warnings anymore...

I edited this:

[small]

register_clcmd("item_mphone","item_mphone")

[small]

to this:

[small]

register_srvcmd("item_mphone","item_mphone")

[small]

and now the sound works, if I use the clcmd, nothin works.

But I have a problem, this one that comes in server's console:

[AMXX] Native error in "set_user_origin" on line 28 (file "matrix_phone.sma").


We are going to make it, I'll give all you some karma!

hey, how to give karma?

kuidao 05-05-2006 14:18

[small]
----------------------------------------------------------------
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
#include <fakemeta>

new porigin[3] = { -326, 152, -25 }


public plugin_init() {
register_plugin("Matrix Phone", "1.0", "Kuidao Ketemeto")
register_clcmd("item_mphone","item_mphone")
}

// Precaching some stuff
public plugin_precache()
{
precache_sound("items/kuidao/teleport.wav")
}

////////////////////////////////////
// ITEM
///////////////////////////////////

// The Matrix Phone
public item_mphone(id)
{
set_user_origin(id, porigin) // Moves the player to the location stored in origin
client_cmd(id,"speak ^"items/kuidao/teleport^"")
return PLUGIN_HANDLED
}
----------------------------------------------
[small]

ok, Sean D told me to do this, well, thanks, no warnings anymore...

I edited this:

[small]

register_clcmd("item_mphone","item_mphone")

[small]

to this:

[small]

register_srvcmd("item_mphone","item_mphone")

[small]

and now the sound works, if I use the clcmd, nothin works.

But I have a problem, this one that comes in server's console:

[AMXX] Native error in "set_user_origin" on line 28 (file "matrix_phone.sma").


We are going to make it, I'll give all you some karma!


All times are GMT -4. The time now is 05:05.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.