AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Exp Base - Classname help? (https://forums.alliedmods.net/showthread.php?t=154756)

Erox902 04-12-2011 17:11

Exp Base - Classname help?
 
Hey i'm trying to make a basic xp mod.. but I want people to gain "Classname" instead of choosing like:
Code:
public Deathmsg() { new attacker = read_data(1) new victim = read_data(2) blablabla playerExp[id] += bla; while(playerLevel[id] >= 5 { playerClass[id] = 1//in this case "animal planet" } while(playerLevel[id] >= 10 { playerClass[id] = 2//in this case "star wars" }

I have tried several ways but this way worked untill it was time to change classname that will say... at that point it froze cs totaly :/
Code:
#include <amxmodx> #include <amxmisc> #define MAXCLASSES 5 enum {     CLASS_HORSESHOE = 0,     CLASS_ANIMALPLANET = 1,     CLASS_STARWARS = 2,     CLASS_HARRYPOTTER = 3,     CLASS_MRMIME = 4 } new const CLASSES[MAXCLASSES][] ={     "Horse Shoe",     "Animal Planet",     "Star Wars",     "Harry Potter",     "Mr Mime" };
... Awesome Classnames xD
and for the way to show it I use a menu like:
Code:
new MainTitle[128]     format(MainTitle, 127, "\rExpMod^n\wMain Menu^n^nExp: \y%i^n\wLvl: \y%i^n\wClass: \y%s", playerExp[id], playerLevel[id], CLASSES[playerClass[id]]); new Main = menu_create(MainTitle, "handleMain");
Anyone think they know how to fix this?... not that great with enums :/

Erox902 04-26-2011 17:11

Re: Exp Base - Classname help?
 
bump

.Dare Devil. 04-26-2011 17:16

Re: Exp Base - Classname help?
 
"Harry Potter",
"Mr Mime"
xD harry potter :)
Please post full code i can help i think...

SonicSonedit 04-26-2011 17:30

Re: Exp Base - Classname help?
 
Quote:

I have tried several ways but this way worked untill it was time to change classname that will say... at that point it froze cs totaly :/
Explain more clearly please.

Erox902 04-27-2011 09:22

Re: Exp Base - Classname help?
 
Quote:

Originally Posted by SonicSonedit (Post 1458523)
Explain more clearly please.

I want to make a exp mod, the thing about it is that i don't want people to be able to choose what "class" they will be, like in uwc3ng and such... I want them to have the "classname" "harry potter" for example the first time they join... now when they level up to example lvl 5 they will change "classname" to something else, but what i exactly meant with cs freezing is that when it starts to "loop the levels" to see if he is in high lvl enough to get the new "classname", then cs freezes and i have to quit it with ctrl+alt+del :cry:... accually i said that i used if statements but thats not true i'm looping them in the deathmsg... will edit in a sec...

aaarnas 04-27-2011 09:30

Re: Exp Base - Classname help?
 
If it freezes, it mean, that you created eternal cycle somewhere. Mostly expected while cycle.

Erox902 04-27-2011 09:31

Re: Exp Base - Classname help?
 
eternal cycle? :S like looping doesn't stop or how do you mean?

aaarnas 04-27-2011 09:59

Re: Exp Base - Classname help?
 
Yes. Let's say something like this:
PHP Code:

program() {
    
    new 
abc
    b 
1
    
while(b) {
        
        
c++
        
c
    
}


This cycle will newer end, and after it comes, server(not client) console freezes and doesn't react at anything.

SonicSonedit 04-27-2011 10:00

Re: Exp Base - Classname help?
 
Erox902
Cycle like
PHP Code:

for (i=1i>0;i++) 

will never end.
Show all code.

SonicSonedit 04-27-2011 10:14

Re: Exp Base - Classname help?
 
PHP Code:

public Classname(id)
{
   while(
playerLvl[id] >= 5)
   {
        
playerClass[id] = 1;
   }
   while(
playerLvl[id] >= 12)
   {
        
playerClass[id] = 2;
   }
   while(
playerLvl[id] >= 19)
   {
        
playerClass[id] = 3;
   }
   while(
playerLvl[id] >= 25)
   {
        
playerClass[id] = 4;
   }


Wow. It's supposed to be like this:
PHP Code:

public Classname(id)
{
   if (
playerLvl[id] >= 5)
        
playerClass[id] = 1;
   
   if (
playerLvl[id] >= 12)
        
playerClass[id] = 2;
   
   if (
playerLvl[id] >= 19)
        
playerClass[id] = 3;
   
   if (
playerLvl[id] >= 25)
        
playerClass[id] = 4;




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

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