AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   number not increasing correctly? (https://forums.alliedmods.net/showthread.php?t=12581)

Bone 04-18-2005 17:17

number not increasing correctly?
 
ok for my lockpick plug in i am making it so how many sucessfull lock picking you done makes you gain lock picking skills.. etc. problem is thou that its not doing it right. here is code.

Code:
  //////////////////////////////////////////////////////////////////////////////////////////  // Lockskill level one  //////////////////////////////////////////////////////////////////////////////////////////  public lockskillone(id) {     /*if(!cmd_access(id,level,cid,1)) {     return PLUGIN_HANDLED;     }*/     new doorid, doorbody, isdoor;         new pick = random_num(0, 20)         new increase = 0;         new breakpick = random_num(0, 20)     get_user_aiming(id,doorid,doorbody,9999);     if(is_valid_ent(doorid)) { // if valid ent         isdoor = is_door(doorid);     }     else { // if invalid ent         client_print(id,print_chat,"* [DOOR] Door is invalid or non-existant^n");         return PLUGIN_HANDLED;     }     if(isdoor == 0) { // if not a door entity         if(is_button(doorid)) { // if really a button             buttonuse(id); // go to button use             return PLUGIN_HANDLED;         }         client_print(id,print_chat,"* [LockPick] Must be near Door to lockpick^n");         return PLUGIN_HANDLED;     }     if(doorid > MAXDOORS-1) { // if exceeds our array         client_print(id,print_chat,"* [DOOR] ERROR: Too many entities^n");         return PLUGIN_HANDLED;     }     if(pick < 15) { // if lockpick doesnt work         client_print(id,print_chat,"* [LockPick] LockPick not successfull^n");         return PLUGIN_HANDLED;     }         if(breakpick == 3) { // Breakpick         client_print(id,print_chat,"* [LockPick] You broke your lockpick^n");                 canpick = 0;         return PLUGIN_HANDLED;     }         if(increase == 5) { // Breakpick         client_print(id,print_chat,"* [LockPick] Your lockpicking skill has increased to level 2^n");                 lockskill = 2;                 set_task(0.1, "employmentstatus", id);         return PLUGIN_HANDLED;     }         if(breakpick == 10) { // Breakpick         client_print(id,print_chat,"* [LockPick] You broke your lockpick^n");                 canpick = 0;         return PLUGIN_HANDLED;     }         if(breakpick == 19) { // Breakpick         client_print(id,print_chat,"* [LockPick] You broke your lockpick^n");                 canpick = 0;         return PLUGIN_HANDLED;     }         // gotta wait to picklock foo'         if(canpick <= 0) {             client_print(id,print_chat,"* [LOCKPICK] You do not have a lockpick, buy one from admin.^n");             return PLUGIN_HANDLED;         }     force_use(id,doorid); // use the darn door         client_print(id,print_chat,"* [LockPick] Door has been LockPicked Sucessfully^n");         increase += 1;         set_task(0.1, "picklock", id);     return PLUGIN_HANDLED;  }  //////////////////////////////////////////////////////////////////////////////////////////  // Lockskill level two  //////////////////////////////////////////////////////////////////////////////////////////  public lockskilltwo(id) {     /*if(!cmd_access(id,level,cid,1)) {     return PLUGIN_HANDLED;     }*/     new doorid, doorbody, isdoor;         new pick = random_num(0, 20)         new breakpick = random_num(0, 20)         new increase = 0;     get_user_aiming(id,doorid,doorbody,9999);     if(is_valid_ent(doorid)) { // if valid ent         isdoor = is_door(doorid);     }     else { // if invalid ent         client_print(id,print_chat,"* [DOOR] Door is invalid or non-existant^n");         return PLUGIN_HANDLED;     }     if(isdoor == 0) { // if not a door entity         if(is_button(doorid)) { // if really a button             buttonuse(id); // go to button use             return PLUGIN_HANDLED;         }         client_print(id,print_chat,"* [LockPick] Must be near Door to lockpick^n");         return PLUGIN_HANDLED;     }     if(doorid > MAXDOORS-1) { // if exceeds our array         client_print(id,print_chat,"* [DOOR] ERROR: Too many entities^n");         return PLUGIN_HANDLED;     }     if(pick < 12) { // if lockpick doesnt work         client_print(id,print_chat,"* [LockPick] LockPick not successfull^n");         return PLUGIN_HANDLED;     }         if(breakpick == 3) { // Breakpick         client_print(id,print_chat,"* [LockPick] You broke your lockpick^n");                 canpick = 0;         return PLUGIN_HANDLED;     }         if(increase == 30) { // Breakpick         client_print(id,print_chat,"* [LockPick] Your lockpicking skill has increased to level 3^n");                 lockskill = 3;                 set_task(0.1, "employmentstatus", id);         return PLUGIN_HANDLED;     }         if(breakpick == 19) { // Breakpick         client_print(id,print_chat,"* [LockPick] You broke your lockpick^n");                 canpick = 0;         return PLUGIN_HANDLED;     }         // gotta wait to picklock foo'         if(canpick <= 0) {             client_print(id,print_chat,"* [LOCKPICK] You do not have a lockpick, buy one from admin.^n");             return PLUGIN_HANDLED;         }     force_use(id,doorid); // use the darn door         client_print(id,print_chat,"* [LockPick] Door has been LockPicked Sucessfully^n");         increase += 1;         set_task(0.1, "picklock", id);     return PLUGIN_HANDLED;  }  //////////////////////////////////////////////////////////////////////////////////////////  // Lockskill level three  //////////////////////////////////////////////////////////////////////////////////////////  public lockskillthree(id) {     /*if(!cmd_access(id,level,cid,1)) {     return PLUGIN_HANDLED;     }*/     new doorid, doorbody, isdoor;         new pick = random_num(0, 20)         new breakpick = random_num(0, 20)         new increase = 0;     get_user_aiming(id,doorid,doorbody,9999);     if(is_valid_ent(doorid)) { // if valid ent         isdoor = is_door(doorid);     }     else { // if invalid ent         client_print(id,print_chat,"* [DOOR] Door is invalid or non-existant^n");         return PLUGIN_HANDLED;     }     if(isdoor == 0) { // if not a door entity         if(is_button(doorid)) { // if really a button             buttonuse(id); // go to button use             return PLUGIN_HANDLED;         }         client_print(id,print_chat,"* [LockPick] Must be near Door to lockpick^n");         return PLUGIN_HANDLED;     }     if(doorid > MAXDOORS-1) { // if exceeds our array         client_print(id,print_chat,"* [DOOR] ERROR: Too many entities^n");         return PLUGIN_HANDLED;     }     if(pick < 10) { // if lockpick doesnt work         client_print(id,print_chat,"* [LockPick] LockPick not successfull^n");         return PLUGIN_HANDLED;     }         if(breakpick == 3) { // Breakpick         client_print(id,print_chat,"* [LockPick] You broke your lockpick^n");                 canpick = 0;         return PLUGIN_HANDLED;     }         if(increase == 40) { // Breakpick         client_print(id,print_chat,"* [LockPick] Your lockpicking skill has increased to level 4 ^n");                 lockskill = 4;                 set_task(0.1, "employmentstatus", id);         return PLUGIN_HANDLED;     }         // gotta wait to picklock foo'         if(canpick <= 0) {             client_print(id,print_chat,"* [LOCKPICK] You do not have a lockpick, buy one from admin.^n");             return PLUGIN_HANDLED;         }     force_use(id,doorid); // use the darn door         client_print(id,print_chat,"* [LockPick] Door has been LockPicked Sucessfully^n");         increase += 1;         set_task(0.1, "picklock", id);     return PLUGIN_HANDLED;  }  //////////////////////////////////////////////////////////////////////////////////////////  // Lockskill level four  //////////////////////////////////////////////////////////////////////////////////////////  public lockskillfour(id) {     /*if(!cmd_access(id,level,cid,1)) {     return PLUGIN_HANDLED;     }*/     new doorid, doorbody, isdoor;         new pick = random_num(0, 20)         new breakpick = random_num(0, 20)         new increase = 0;     get_user_aiming(id,doorid,doorbody,9999);     if(is_valid_ent(doorid)) { // if valid ent         isdoor = is_door(doorid);     }     else { // if invalid ent         client_print(id,print_chat,"* [DOOR] Door is invalid or non-existant^n");         return PLUGIN_HANDLED;     }     if(isdoor == 0) { // if not a door entity         if(is_button(doorid)) { // if really a button             buttonuse(id); // go to button use             return PLUGIN_HANDLED;         }         client_print(id,print_chat,"* [LockPick] Must be near Door to lockpick^n");         return PLUGIN_HANDLED;     }     if(doorid > MAXDOORS-1) { // if exceeds our array         client_print(id,print_chat,"* [DOOR] ERROR: Too many entities^n");         return PLUGIN_HANDLED;     }     if(pick < 8) { // if lockpick doesnt work         client_print(id,print_chat,"* [LockPick] LockPick not successfull^n");         return PLUGIN_HANDLED;     }         if(breakpick == 1) { // Breakpick         client_print(id,print_chat,"* [LockPick] You broke your lockpick^n");                 canpick = 0;         return PLUGIN_HANDLED;     }         if(increase == 50) { // Breakpick         client_print(id,print_chat,"* [LockPick] Your lockpicking skill has increased to level 5 ^n");                 lockskill = 5;                 set_task(0.1, "employmentstatus", id);         return PLUGIN_HANDLED;     }         // gotta wait to picklock foo'         if(canpick <= 0) {             client_print(id,print_chat,"* [LOCKPICK] You do not have a lockpick, buy one from admin.^n");             return PLUGIN_HANDLED;         }     force_use(id,doorid); // use the darn door         client_print(id,print_chat,"* [LockPick] Door has been LockPicked Sucessfully^n");         increase += 1;         set_task(0.1, "picklock", id);     return PLUGIN_HANDLED;  }  //////////////////////////////////////////////////////////////////////////////////////////  // Lockskill level five  //////////////////////////////////////////////////////////////////////////////////////////  public lockskillfive(id) {     /*if(!cmd_access(id,level,cid,1)) {     return PLUGIN_HANDLED;     }*/     new doorid, doorbody, isdoor;         new breakpick = random_num(0, 20)     get_user_aiming(id,doorid,doorbody,9999);     if(is_valid_ent(doorid)) { // if valid ent         isdoor = is_door(doorid);     }     else { // if invalid ent         client_print(id,print_chat,"* [DOOR] Door is invalid or non-existant^n");         return PLUGIN_HANDLED;     }     if(isdoor == 0) { // if not a door entity         if(is_button(doorid)) { // if really a button             buttonuse(id); // go to button use             return PLUGIN_HANDLED;         }         client_print(id,print_chat,"* [LockPick] Must be near Door to lockpick^n");         return PLUGIN_HANDLED;     }     if(doorid > MAXDOORS-1) { // if exceeds our array         client_print(id,print_chat,"* [DOOR] ERROR: Too many entities^n");         return PLUGIN_HANDLED;     }         if(breakpick == 15) { // Breakpick         client_print(id,print_chat,"* [LockPick] You broke your lockpick^n");                 canpick = 0;         return PLUGIN_HANDLED;     }         // gotta wait to picklock foo'         if(canpick <= 0) {             client_print(id,print_chat,"* [LOCKPICK] You do not have a lockpick, buy one from admin.^n");             return PLUGIN_HANDLED;         }     force_use(id,doorid); // use the darn door         client_print(id,print_chat,"* [LockPick] Door has been LockPicked Sucessfully^n");         set_task(0.1, "picklock", id);     return PLUGIN_HANDLED;  }

the problem is its that it doesnt seem to increase or something i tried setting it to if increase is 2 then it levels up but no matter how many times i am sucessfull ti never levels up

XxAvalanchexX 04-18-2005 21:32

Code:
increase = 0

Code:
if(increase == 50)

What did you expect?

P.S. Why do you have 5 functions for the same thing?

Bone 04-19-2005 09:04

damn i forgot i set it to 0 each time, thanks tons.

and reason is cause each funtion is different like your odds of opening lock etc greatly increases

Bone 04-19-2005 16:25

its still not working, i just got home and tried it. here is my code


Code:
 //////////////////////////////////////////////////////////////////////////////////////////  // Picklock  //////////////////////////////////////////////////////////////////////////////////////////  public picklocktwo(id) {     /*if(!cmd_access(id,level,cid,1)) {     return PLUGIN_HANDLED;     }*/     new doorid, doorbody, isdoor;     get_user_aiming(id,doorid,doorbody,9999);     if(is_valid_ent(doorid)) { // if valid ent         isdoor = is_door(doorid);     }     else { // if invalid ent         client_print(id,print_chat,"* [DOOR] Door is invalid or non-existant^n");         return PLUGIN_HANDLED;     }     if(isdoor == 0) { // if not a door entity         if(is_button(doorid)) { // if really a button             buttonuse(id); // go to button use             return PLUGIN_HANDLED;         }         client_print(id,print_chat,"* [LockPick] Must be near Door to lockpick^n");         return PLUGIN_HANDLED;     }     if(doorid > MAXDOORS-1) { // if exceeds our array         client_print(id,print_chat,"* [DOOR] ERROR: Too many entities^n");         return PLUGIN_HANDLED;     }         if(lockskill == 1) { // if lockpick doesnt work         set_task(0.1, "lockskillone", id);         return PLUGIN_HANDLED;     }         if(lockskill == 2) { // Breakpick                 set_task(0.1, "lockskilltwo", id);         return PLUGIN_HANDLED;     }         if(lockskill == 3) { // Breakpick                 set_task(0.1, "lockskillthree", id);         return PLUGIN_HANDLED;     }         if(lockskill == 4) { // Breakpick                 set_task(0.1, "lockskillfour", id);         return PLUGIN_HANDLED;     }         if(lockskill == 5) { // Breakpick                 set_task(0.1, "lockskillfive", id);         return PLUGIN_HANDLED;     }
Code:
 //////////////////////////////////////////////////////////////////////////////////////////  // Lockskill level one  //////////////////////////////////////////////////////////////////////////////////////////  public lockskillone(id) {     /*if(!cmd_access(id,level,cid,1)) {     return PLUGIN_HANDLED;     }*/     new doorid, doorbody, isdoor;         new pick = random_num(0, 20)         new increase         new breakpick = random_num(0, 20)     get_user_aiming(id,doorid,doorbody,9999);     if(is_valid_ent(doorid)) { // if valid ent         isdoor = is_door(doorid);     }     else { // if invalid ent         client_print(id,print_chat,"* [DOOR] Door is invalid or non-existant^n");         return PLUGIN_HANDLED;     }     if(isdoor == 0) { // if not a door entity         if(is_button(doorid)) { // if really a button             buttonuse(id); // go to button use             return PLUGIN_HANDLED;         }         client_print(id,print_chat,"* [LockPick] Must be near Door to lockpick^n");         return PLUGIN_HANDLED;     }     if(doorid > MAXDOORS-1) { // if exceeds our array         client_print(id,print_chat,"* [DOOR] ERROR: Too many entities^n");         return PLUGIN_HANDLED;     }     if(pick < 15) { // if lockpick doesnt work         client_print(id,print_chat,"* [LockPick] LockPick not successfull^n");         return PLUGIN_HANDLED;     }         if(breakpick == 3) { // Breakpick         client_print(id,print_chat,"* [LockPick] You broke your lockpick^n");                 canpick = 0;         return PLUGIN_HANDLED;     }         if(increase == 2) { // Breakpick         client_print(id,print_chat,"* [LockPick] Your lockpicking skill has increased to level 2^n");                 lockskill = 2;                 set_task(0.1, "employmentstatus", id);         return PLUGIN_HANDLED;     }         if(breakpick == 10) { // Breakpick         client_print(id,print_chat,"* [LockPick] You broke your lockpick^n");                 canpick = 0;         return PLUGIN_HANDLED;     }         if(breakpick == 19) { // Breakpick         client_print(id,print_chat,"* [LockPick] You broke your lockpick^n");                 canpick = 0;         return PLUGIN_HANDLED;         }         // gotta wait to picklock foo'         if(canpick <= 0) {             client_print(id,print_chat,"* [LOCKPICK] You do not have a lockpick, buy one from admin.^n");             return PLUGIN_HANDLED;         }     force_use(id,doorid); // use the darn door         client_print(id,print_chat,"* [LockPick] Door has been LockPicked Sucessfully^n");         increase += 1;         set_task(0.1, "picklock", id);     return PLUGIN_HANDLED;  }  //////////////////////////////////////////////////////////////////////////////////////////  // Lockskill level two  //////////////////////////////////////////////////////////////////////////////////////////  public lockskilltwo(id) {     /*if(!cmd_access(id,level,cid,1)) {     return PLUGIN_HANDLED;     }*/     new doorid, doorbody, isdoor;         new pick = random_num(0, 20)         new breakpick = random_num(0, 20)         new increase     get_user_aiming(id,doorid,doorbody,9999);     if(is_valid_ent(doorid)) { // if valid ent         isdoor = is_door(doorid);     }     else { // if invalid ent         client_print(id,print_chat,"* [DOOR] Door is invalid or non-existant^n");         return PLUGIN_HANDLED;     }     if(isdoor == 0) { // if not a door entity         if(is_button(doorid)) { // if really a button             buttonuse(id); // go to button use             return PLUGIN_HANDLED;         }         client_print(id,print_chat,"* [LockPick] Must be near Door to lockpick^n");         return PLUGIN_HANDLED;     }     if(doorid > MAXDOORS-1) { // if exceeds our array         client_print(id,print_chat,"* [DOOR] ERROR: Too many entities^n");         return PLUGIN_HANDLED;     }     if(pick < 12) { // if lockpick doesnt work         client_print(id,print_chat,"* [LockPick] LockPick not successfull^n");         return PLUGIN_HANDLED;     }         if(breakpick == 3) { // Breakpick         client_print(id,print_chat,"* [LockPick] You broke your lockpick^n");                 canpick = 0;         return PLUGIN_HANDLED;     }         if(increase == 2) { // Breakpick         client_print(id,print_chat,"* [LockPick] Your lockpicking skill has increased to level 3^n");                 lockskill = 3;                 set_task(0.1, "employmentstatus", id);         return PLUGIN_HANDLED;     }         if(breakpick == 19) { // Breakpick         client_print(id,print_chat,"* [LockPick] You broke your lockpick^n");                 canpick = 0;         return PLUGIN_HANDLED;     }         // gotta wait to picklock foo'         if(canpick <= 0) {             client_print(id,print_chat,"* [LOCKPICK] You do not have a lockpick, buy one from admin.^n");             return PLUGIN_HANDLED;         }     force_use(id,doorid); // use the darn door         client_print(id,print_chat,"* [LockPick] Door has been LockPicked Sucessfully^n");         increase += 1;         set_task(0.1, "picklock", id);     return PLUGIN_HANDLED;  }

XxAvalanchexX 04-19-2005 16:56

Code:
new increase
and
Code:
new increase = 0
do the same thing. You have to give increase some value, maybe using random_num?

Bone 04-19-2005 17:11

that would cause a problem wouldnt it... cause it would make a new random number everytime... and then i would have same prob of when it was set to 1 everytime :-/ anyone have a solution?

slurpycof 04-19-2005 17:24

How are you storing a user's points to determine level? Is it for that map only or is it stored for a long time using sql/vault? This is not hard to make work either way, just need to know which way you want.

Bone 04-19-2005 17:38

i would like it to be stores in vault and when he gains level it saves it in vault

so it saves his lockskill level as well as how many points he has.

slurpycof 04-19-2005 20:14

give this a shot
Code:
#include <vault> new lockskill[33] public plugin_init()[     register_cvar("amx_picklvl","5")//points required for each level }   public client_authorized(id){     new authid[32]     get_user_authid(id,authid,31)     if (is_user_hltv(id) ) {  //Do not do anything         return PLUGIN_CONTINUE     }     if ( is_user_bot(id) ) {  //Do not do anything         return PLUGIN_CONTINUE     }     if(vaultdata_exists(authid)){         new vault_lockskill[32]         get_vaultdata(authid,vault_lockskill,31)         lockskill[id] = str_to_num(vault_lockskill)     }else{//No data exists         lockskill[id] = 0     }     return PLUGIN_CONTINUE } public lockskillone(id) {     //BLAH BLAH BLAH     force_use(id,doorid); // use the darn door     client_print(id,print_chat,"* [LockPick] Door has been LockPicked Sucessfully^n");     lockskill[id]++     set_task(0.1, "picklock", id)     return PLUGIN_HANDLED }     public client_disconnect (id){     if ( is_user_bot(id) ) {  //Do not add to database         return PLUGIN_CONTINUE     }     if (is_user_hltv(id) ) {  //Do not add to database         return PLUGIN_CONTINUE     }     new authid[32]     get_user_authid(id,authid,31)     new vault_lockskill[32]     num_to_str(lockskill[id],vault_lockskill,31)     set_vaultdata(authid,vault_lockskill)     return PLUGIN_HANDLED }      public query_picklevel(id, level, cid){     new message [192]     read_args(message, 190)     remove_quotes(message)     if (containi(message,"/picklevel")!=-1) {         if (lockskill[id]== 0) {             client_print(id,print_chat,"You are still a level one lockpicker")         }else{             new picklevel             picklevel = (lockskill[id] / get_cvar_num("amx_picklvl")) //not sure if this works or if you need to assign cvar to a new variable             client_print(id,print_chat,"You are a level %i lockpicker",picklevel)         }         return PLUGIN_HANDLED     }     return PLUGIN_CONTINUE  }

v3x 04-19-2005 20:23

Quote:

Code:
public plugin_init()[

:roll:


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

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