AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   What is wrong with it? (https://forums.alliedmods.net/showthread.php?t=25426)

TiToTal 03-13-2006 18:57

What is wrong with it?
 
I don't know... here is the code:
Code:
public something(id) {     new players[32], num     get_players(players,num,"ac")     for(new i = 0; i < num;i++)     {         new origin[3]         get_user_origin(id,origin)         if(get_distance(origin,casaum) <= 100.0 || get_distance(origin,casadois) <= 100.0 || get_distance(origin,casatres) <= 100.0 || get_distance(origin,casaquatro) <= 100.0 || get_distance(origin,casacinco) <= 110.0 || get_distance(origin,casaseis) <= 110.0 || get_distance(origin,casasete) <= 110.0 || get_distance(origin,casaoito) <= 110.0 || get_distance(origin,casanove) <= 110.0 || get_distance(origin,casadez) <= 110.0 ||         get_distance(origin,umcasa) <= 100.0 || get_distance(origin,doiscasa) <= 100.0 || get_distance(origin,trescasa) <= 100.0 || get_distance(origin,quatrocasa) <= 100.0 || get_distance(origin,cincocasa) <= 110.0 || get_distance(origin,seiscasa) <= 110.0 || get_distance(origin,setecasa) <= 110.0 || get_distance(origin,oitocasa) <= 110.0 || get_distance(origin,novecasa) <= 110.0 || get_distance(origin,dezcasa) <= 110.0)         {             //code         }         if(get_distance(origin,casaum) > 100.0 || get_distance(origin,casadois) > 100.0 || get_distance(origin,casatres) > 100.0 || get_distance(origin,casaquatro) > 100.0 || get_distance(origin,casacinco) > 110.0 || get_distance(origin,casaseis) > 110.0 || get_distance(origin,casasete) > 110.0 || get_distance(origin,casaoito) > 110.0 || get_distance(origin,casanove) > 110.0 || get_distance(origin,casadez) > 110.0 ||         get_distance(origin,umcasa) > 100.0 || get_distance(origin,doiscasa) > 100.0 || get_distance(origin,trescasa) > 100.0 || get_distance(origin,quatrocasa) > 100.0 || get_distance(origin,cincocasa) > 110.0 || get_distance(origin,seiscasa) > 110.0 || get_distance(origin,setecasa) > 110.0 || get_distance(origin,oitocasa) > 110.0 || get_distance(origin,novecasa) > 110.0 || get_distance(origin,dezcasa) > 110.0)         {             //code         }         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED }


It compiles normally...

but here is the console error message:

L 03/13/2006 - 20:54:30: [AMXX] Native error in "get_user_origin" on line 7590 (file "test.sma").


It doesn't executes after "if" because it can't get the origin... I don't know why...


can someone say what is wrong with this?

Kraugh 03-13-2006 20:23

it looks like what you meant to do was put "players[i]" instead of "id". that is only in the for loop, not for anything outside of it.

TiToTal 03-13-2006 21:29

Quote:

Originally Posted by Kraugh
it looks like what you meant to do was put "players[i]" instead of "id". that is only in the for loop, not for anything outside of it.

but when I use players[i] the script only works with the first players who joins the server... so, I thought I had to put ID instead of players[i]...

EDIT: actually I don't know if it works only for the first who joined... but I tested this plugin with my friend, and both times we tested, who got in first got the plugin working correctly... and the other didn't... (sorry my english... I think you can understand :)

Charr 03-14-2006 12:56

It is because of the id. players[i] or i would be correct to use. Also you dont need the id in the header.

TiToTal 03-14-2006 13:59

Quote:

Originally Posted by Charr
It is because of the id. players[i] or i would be correct to use. Also you dont need the id in the header.

But players[i] didn't work properly =/

Kraugh 03-14-2006 16:22

try it again anyway and let us know how it goes.

TiToTal 03-14-2006 21:44

Quote:

Originally Posted by Kraugh
try it again anyway and let us know how it goes.

here is the problem... nothing happens.. =(
The code works perfectly with the first to join the server (I tested this plugin ONLY whit 2 people in the server)...

But nothing, nothing happens to the second one... I can't believe something is wrong... but definately there is something =(

Kraugh 03-14-2006 23:02

show me the rest of the code.

TiToTal 03-15-2006 11:07

here is it..
some variables are in portuguese...

(It's a code I made for harbu pulgin)

Code:
public something() {     new players[32], num     get_players(players,num,"ac")     for(new i = 0; i < num;i++)     {         new origin[3]         get_user_origin(players[i],origin)         if(get_distance(origin,casaum) <= 100.0 || get_distance(origin,casadois) <= 100.0 || get_distance(origin,casatres) <= 100.0 || get_distance(origin,casaquatro) <= 100.0 || get_distance(origin,casacinco) <= 110.0 || get_distance(origin,casaseis) <= 110.0 || get_distance(origin,casasete) <= 110.0 || get_distance(origin,casaoito) <= 110.0 || get_distance(origin,casanove) <= 110.0 || get_distance(origin,casadez) <= 110.0 ||         get_distance(origin,umcasa) <= 100.0 || get_distance(origin,doiscasa) <= 100.0 || get_distance(origin,trescasa) <= 100.0 || get_distance(origin,quatrocasa) <= 100.0 || get_distance(origin,cincocasa) <= 110.0 || get_distance(origin,seiscasa) <= 110.0 || get_distance(origin,setecasa) <= 110.0 || get_distance(origin,oitocasa) <= 110.0 || get_distance(origin,novecasa) <= 110.0 || get_distance(origin,dezcasa) <= 110.0)         {             if(is_user_database(players[i]) == 1)             {                 new query[256], authid[32]                 get_user_authid(players[i],authid,31)                 format(query,255,"SELECT sono FROM money WHERE steamid='%s'",authid)                 result = dbi_query(dbc,query)                 if(dbi_nextrow(result) > 0)                 {                     new currentsono = dbi_field(result,1)                     dbi_free_result(result)                     if(currentsono > 0)                     {                         edit_value(players[i],"money","sono","-",10)                     }                 }                 dbi_free_result(result)             }             return PLUGIN_HANDLED         }         if(get_distance(origin,casaum) > 100.0 || get_distance(origin,casadois) > 100.0 || get_distance(origin,casatres) > 100.0 || get_distance(origin,casaquatro) > 100.0 || get_distance(origin,casacinco) > 110.0 || get_distance(origin,casaseis) > 110.0 || get_distance(origin,casasete) > 110.0 || get_distance(origin,casaoito) > 110.0 || get_distance(origin,casanove) > 110.0 || get_distance(origin,casadez) > 110.0 ||         get_distance(origin,umcasa) > 100.0 || get_distance(origin,doiscasa) > 100.0 || get_distance(origin,trescasa) > 100.0 || get_distance(origin,quatrocasa) > 100.0 || get_distance(origin,cincocasa) > 110.0 || get_distance(origin,seiscasa) > 110.0 || get_distance(origin,setecasa) > 110.0 || get_distance(origin,oitocasa) > 110.0 || get_distance(origin,novecasa) > 110.0 || get_distance(origin,dezcasa) > 110.0)         {             new ran = random_num(1,2)             if(ran == 1)             {                 if(is_user_database(players[i]) == 1)                 {                     edit_value(players[i],"money","sono","+",random_num(1,2))                     new query[256], authid[32]                     get_user_authid(players[i],authid,31)                     format(query,255,"SELECT sono FROM money WHERE steamid='%s'",authid)                     result = dbi_query(dbc,query)                     if(dbi_nextrow(result) > 0)                     {                         new currentsono = dbi_field(result,1)                         dbi_free_result(result)                         if(currentsono >= 100)                         {                             client_print(players[i],print_chat,"[Sono Mod] Voce desmaiou de sono!^n")                             edit_value(players[i],"money","sono","=",90)                             set_user_maxspeed(players[i],-1.0)                             set_task(2.0,"desmaiar",players[i])                             set_task(30.0,"acordar",players[i])                         }                     }                     dbi_free_result(result)                 }             }         }         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED }

Kraugh 03-15-2006 15:48

how is your something function called?


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

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