AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] (https://forums.alliedmods.net/showthread.php?t=159823)

Excalibur.007 06-22-2011 01:25

[SOLVED]
 
Problem solved, Thanks fysiks

fysiks 06-22-2011 03:07

Re: 2 problems
 
1. :arrow:
PHP Code:

new const RANKS[][] = 



Excalibur.007 06-22-2011 03:44

Re: 2 problems
 
Yeah. I tried that. But how do we put it in a statement.

PHP Code:

client_printcolor(id"/g[ZP Ranks] /yRank:/g %s /y| EXP:/g %d /y| EXP to next rank:/g %d"RANKS[iRank[id]], iXP[id], EXP[iRank[id] + 1]) 

I had compile problems Array must be indexed.

fysiks 06-22-2011 03:46

Re: 2 problems
 
If you made the change I suggested (adding the []) then I don't see anything wrong. You have RANKS indexed correctly for what it is being used for.

Excalibur.007 06-22-2011 03:51

Re: 2 problems
 
Quote:

Originally Posted by fysiks (Post 1493310)
If you made the change I suggested (adding the []) then I don't see anything wrong. You have RANKS indexed correctly for what it is being used for.

Oh yeah. Your correct. It's the problem with the EXP.

PHP Code:

new const EXP[][]=
{
    
0// 0
    
0// 1
    
50// 2
    
100// 3
    
200// 4
    
400// 5
    
800// 6
    
1600// 7
    
3200// 8
    
6400// 9
    
12800// 10
    
25600// 11
    
51200// 12
    
102400// 13
    
204800// 14
    
409600// 15
    
819200// 16
    
1638400// 17
    
3276800// 18
    
6553600 // 19


I don't think we need 2 [] right, because it doesn't have quotes and it compiles fine with one []

PHP Code:

if(iXP[iKiller] >= EXP[iRank[iKiller]] && iRank[iKiller] < 19


fysiks 06-22-2011 14:15

Re: 2 problems
 
I did not say to change anything about EXP[]. It was correct before. Only RANKS[] needed changed.

Excalibur.007 06-22-2011 19:34

Re: 2 problems
 
Quote:

Originally Posted by fysiks (Post 1493634)
I did not say to change anything about EXP[]. It was correct before. Only RANKS[] needed changed.

It is now all fixed. Thanks. I messed up EXP with RANKS. Hehe.

Hunter-Digital 06-23-2011 02:52

Re: [SOLVED]
 
Why did you remove the title and code ?
Maybe someone else has the exact same problem and they can't fnid this thread because you removed the title and the code.

Exolent[jNr] 06-23-2011 08:48

Re: [SOLVED]
 
Quote:

Originally Posted by Excalibur.007 (Post 1493262)
2 problems

PHP Code:

new const RANKS[] =
{
"Unranked"// 0
"Private"// 1
"Private 1st Class"// 2
"Corporal"// 3
"Sergeant"// 4
"Staff Sergeant"// 5
"Sergeant 1st Class"// 6
"Master Sergeant"// 7
"Sergeant Major"// 8
"2nd Lieutenant"// 9
"1st Lieutenant"// 10
"Captain"// 11
"Major"// 12
"Lieutenant Colonel"// 13
"Colonel"// 14
"Brigadier General"// 15
"Major General"// 16
"Lieutenant General"// 17
"General"// 18
"General of the Army" // 19
}

new const 
EXP[] =
{
0// 0
0// 1
50// 2
100// 3
200// 4
400// 5
800// 6
1600// 7
3200// 8
6400// 9
12800// 10
25600// 11
51200// 12
102400// 13
204800// 14
409600// 15
819200// 16
1638400// 17
3276800// 18
6553600 // 19
}

new 
g_bitConnectedPlayersg_bitAlivePlayersg_bitZombiePlayers

#define MarkUserConnected(%0) g_bitConnectedPlayers |= (1 << (%0 & 31))
#define ClearUserConnected(%0) g_bitConnectedPlayers &= ~(1 << (%0 & 31))
#define IsUserConnected(%0) g_bitConnectedPlayers & (1 << (%0 & 31))

#define MarkUserAlive(%0) g_bitAlivePlayers |= (1 << (%0 & 31))
#define ClearUserAlive(%0) g_bitAlivePlayers &= ~(1 << (%0 & 31))
#define IsUserAlive(%0) g_bitAlivePlayers & (1 << (%0 & 31))

#define MarkUserZombie(%0) g_bitZombiePlayers |= (1 << (%0 & 31))
#define ClearUserZombie(%0) g_bitZombiePlayers &= ~(1 << (%0 & 31))
#define IsUserZombie(%0) g_bitZombiePlayers & (1 << (%0 & 31))

public plugin_init()
{
register_clcmd("say""hook_say")
register_clcmd("say_team""hook_say_team")
}

public 
hook_say(id)
{
new 
szMessage[192], szName[32]

read_args(szMessage191)
remove_quotes(szMessage)
get_user_name(idszName31)

if(!
is_valid_msg(szMessage))
return 
PLUGIN_CONTINUE

if(IsUserAlive(id))
format(szMessage191"^4[%s] ^3%s : ^1%s"RANKS[iRank[id]], szNameszMessage)
else
format(szMessage191"^1*DEAD* ^4[%s] ^3%s : ^1%s"RANKS[iRank[id]], szNameszMessage)

for(new 
1<= g_iMaxPlayersi++)
{
if(
IsUserConnected(i))
{
if(
IsUserAlive(id) && IsUserAlive(i) || !is_user_alive(id) && !is_user_alive(i))
{
message_begin(MSG_ONEg_msgSayText, {000}, i)
write_byte(id)
write_string(szMessage)
message_end()
}
}
}
return 
PLUGIN_CONTINUE
}

public 
hook_say_team(id)
{
new 
szMessage[192], szName[32]

read_args(szMessage191)
remove_quotes(szMessage)
get_user_name(idszName31)

if(!
is_valid_msg(szMessage))
return 
PLUGIN_HANDLED_MAIN

if(IsUserAlive(id))
format(szMessage191"^4[%s] ^3%s : ^1%s"RANKS[iRank[id]], szNameszMessage)
else
format(szMessage191"^1*DEAD* ^4[%s] ^3%s : ^1%s"RANKS[iRank[id]], szNameszMessage)

for(new 
1<= g_iMaxPlayersi++)
{
if(
IsUserConnected(i))
{
new 
teamid get_user_team(id)
new 
teami get_user_team(i)

if(
IsUserAlive(id) && IsUserAlive(i) && teamid == teami || !is_user_alive(id) && !is_user_alive(i) && teamid == teami)
{
message_begin(MSG_ONEg_msgSayText, {000}, i)
write_byte(id)
write_string(szMessage)
message_end()
}
}
}
return 
PLUGIN_CONTINUE


1. This shows nranked when it supposed to be Private when iRank[id] == 1

PHP Code:

public event_DeathMsg()
{
static 
iVictimiVictim read_data(1)
static 
iKilleriKiller read_data(2)
static 
iIsHeadshotiIsHeadshot read_data(3)

ClearUserAlive(iVictim)

if(
iVictim == iKiller || IsUserZombie(iKiller) || iRank[iKiller] == 0)
return 
HAM_IGNORED

if(IsUserLoggedIn(iKiller))
{
if(
IsUserZombie(iVictim))
{
if(
iIsHeadshot)
iXP[iKiller] += cached_hsxp
else
iXP[iKiller] += cached_xp

if(iXP[iKiller] >= EXP[iRank[iKiller]] && iRank[iKiller] < 19)
{
iRank[iKiller]++

client_printcolor(iKiller"/g[ZP Ranks] /yCongratulations, your rank is now %s"RANKS[iRank[iKiller]])
}
}
}
return 
HAM_IGNORED


2. Doesn't add the XP to the players. Oh and iRank[id] == 0 is when the player isn't registered into the database so that he doesn't gets XP until he registers into the database.

It will automatically sets iRank[id] to 1 when the player registers into the server successfully. But when I type, it shows Nranked when it supposed to be Private. I've checked in the .ini file (Includes all the password for the plugin) It saves the password correctly and works perfectly. I've check also the nVault using nVault Reader. It saves the rank and xp correctly.

Problems:
- It shows [Nranked] *Player's name* : *Message* when it supposed to be private.
- XP doesn't adds even iRank[id] is set to 1. (If it's 0, it will disable that particular player from getting XP)

Don't remove your post after being helped.


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

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