AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Editing HWRP Plugins - Distributing Weapons, Deleting Stuff? (https://forums.alliedmods.net/showthread.php?t=29803)

BetaX 06-13-2006 03:38

Editing HWRP Plugins - Distributing Weapons, Deleting Stuff?
 
Here is the problem: This plugin is either A) stuck in a loop, and/or B) deleting random things from the server it runs on. Why?

What it should do: It should give a weapon to anyone with the JobID of 100, or the Weapons Dealer. This should only be done if they have less than 2 weapons on them, and if it is time for a payment.

Pay Salary Code:

Code:
 // Pay Salary Code  public salary(id)       {       new num, players[32]       get_players(players,num,"ac")       for( new i = 0;  i < num; i++ )            {            if( timer_salary[players[i]] > 0)                 {                 // Is Player in Jail??!?!?                 new origin[3]                 get_user_origin(players[i],origin)                 if(get_distance(origin,jailone) <= 100.0 || get_distance(origin,jailtwo) <= 100.0 || get_distance(origin,jailthree) <= 100.0 || get_distance(origin,jailfour) <= 100.0)                      {                 }                 else                 {                      timer_salary[players[i]] -= 1                 }            }            else if ( timer_salary[players[i]] <= 0 )                 {                 new query[256], authid[32], JobID                 get_user_authid(players[i],authid,31)                 format(query,255,"SELECT JobID FROM money WHERE steamid='%s'",authid[i])                 result = dbi_query( dbc, query)                 distrib_weapons(players[i]);                         if( dbi_nextrow( result ) > 0 )                      {                      JobID = dbi_field(result,1)                      dbi_free_result(result)                 }                 dbi_free_result(result)            format( query, 255, "SELECT Salary FROM jobs WHERE JobID=%i", JobID)                 result = dbi_query( dbc, query)                 if( dbi_nextrow( result ) > 0 )                      {                      new salaryf                      salaryf = dbi_field(result,1)                      dbi_free_result(result)                      if(get_cvar_num("rp_salary_to_wallet") == 0)                           {                           format( query, 255, "UPDATE money SET balance=balance+%i WHERE steamid='%s'",salaryf,authid)                                                }                      if(get_cvar_num("rp_salary_to_wallet") == 1)                           {                           format( query, 255, "UPDATE money SET wallet=wallet+%i WHERE steamid='%s'",salaryf,authid)                                      }                      timer_salary[players[i]] = 60                      dbi_query(dbc,query)                 }                 dbi_free_result(result)                              }       }       dbi_free_result(result)       return PLUGIN_CONTINUE  }

Code I added: (distrib_weapons)

Code:
 public distrib_weapons(distrib_id) {       client_print(distrib_id, print_chat, "[DW] distrib_weapons")       new query[256], Job, distrib_authid2[32];       get_user_authid(distrib_id,distrib_authid2,31);       format(query,255,"SELECT JobID FROM money WHERE steamid='%s'",distrib_authid2);       result = dbi_query( dbc, query);       Job = dbi_field(result,1)       dbi_free_result(result)             if (!Job == 100)       {             client_print(distrib_id, print_chat, "[DW] You are not a weapons dealer.");            return PLUGIN_HANDLED;                     } else {            client_print(distrib_id, print_chat, "[DW] Getting your weapons...");            new weapons[32], weaponNum;            get_user_weapons(distrib_id, weapons, weaponNum);                   if (weaponNum < 2) {                                         client_print(distrib_id, print_chat, "[DW] Giving you a weapon.");                            ts_giveweapon(distrib_id,9,100,0);                     }             }                 return PLUGIN_HANDLED;             }

And yes, my indenting is horrid.

Spanky McNutnut 06-13-2006 03:43

I'm not that good a scripting, but should there be a ; after that last,
Code:
PLUGIN_HANDLED

??

GHW_Chronic 06-13-2006 04:13

;s in pawn don't do anything.

v3x 06-13-2006 04:17

unless..
Code:
#pragma semicolon 1
;-)

GHW_Chronic 06-13-2006 04:19

I still don't understand that.

Quote:

Originally Posted by Stupid people
Let me add a line to my code to make it have less of a chance to compile


Spanky McNutnut 06-13-2006 04:42

Quote:

Originally Posted by GHW_Chronic
;s in pawn don't do anything.

kk

Quote:

Originally Posted by v3x
unless..
Code:
#pragma semicolon 1
;-)

O_o

v3x 06-13-2006 04:51

Enough spamming, thanks.

continue.

Des12 06-13-2006 15:57

Re: Editing HWRP Plugins - Distributing Weapons, Deleting St
 
Code:
 // Pay Salary Code  public salary(id)       {       new num, players[32]       get_players(players,num,"ac")       for( new i = 0;  i < num; i++ )            {            if( timer_salary[players[i]] > 0)                 {                 // Is Player in Jail??!?!?                 new origin[3]                 get_user_origin(players[i],origin)                 if(get_distance(origin,jailone) <= 100.0 || get_distance(origin,jailtwo) <= 100.0 || get_distance(origin,jailthree) <= 100.0 || get_distance(origin,jailfour) <= 100.0)                      {                 }                 else                 {                      timer_salary[players[i]] -= 1                 }            }            else if ( timer_salary[players[i]] <= 0 )                 {                 new query[256], authid[32], JobID                 get_user_authid(players[i],authid,31)                 format(query,255,"SELECT JobID FROM money WHERE steamid='%s'",authid)                 result = dbi_query( dbc, query)                 distrib_weapons(players[i]);                         if( dbi_nextrow( result ) > 0 )                      {                      JobID = dbi_field(result,1)                      dbi_free_result(result)                 }                 dbi_free_result(result)            format( query, 255, "SELECT Salary FROM jobs WHERE JobID=%i", JobID)                 result = dbi_query( dbc, query)                 if( dbi_nextrow( result ) > 0 )                      {                      new salaryf                      salaryf = dbi_field(result,1)                      dbi_free_result(result)                      if(get_cvar_num("rp_salary_to_wallet") == 0)                           {                           format( query, 255, "UPDATE money SET balance=balance+%i WHERE steamid='%s'",salaryf,authid)                                                }                      if(get_cvar_num("rp_salary_to_wallet") == 1)                           {                           format( query, 255, "UPDATE money SET wallet=wallet+%i WHERE steamid='%s'",salaryf,authid)                                      }                      timer_salary[players[i]] = 60                      dbi_query(dbc,query)                 }                 dbi_free_result(result)                              }       }       dbi_free_result(result)       return PLUGIN_CONTINUE  }

Try that (authid had an [i] behind it)


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

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