AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   What worng ? (https://forums.alliedmods.net/showthread.php?t=62231)

elpouletorange 10-21-2007 12:13

What worng ?
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#define MENU_KEYS MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3
#define PLUGIN "Kill mod"
#define VERSION "1.0"
#define AUTHOR "elpouletorange"
#define MAX_PLAYERS 32
new bool:g_restart_attempt[MAX_PLAYERS 1]
new 
str
new def
new dex
new agi
new total
new skp
public plugin_init() 
{
 
register_clcmd("say /menu""kmod_menu")
 
register_menucmd(register_menuid("Select your skills"), MENU_KEYS"choixMenu");
 
register_event("ResetHUD""event_hud_reset""be")
 
register_clcmd("fullupdate""clcmd_fullupdate"
 
register_event("TextMsg""event_restart_attempt""a""2=#Game_will_restart_in")
}
public 
kmod_menu(id

 
skp(id) = get_user_frags(id);  // ERROR !!!
 
total(id) = skp(id) - str(id) - def(id) - dex(id) - agi(id);
 
 if (
total(id) != 0)
 {
  new 
menutext[192]; 
  
format(menutext191"Select your skills^n^n1. Strenght (More Heal)^n2. Defence (More armor)^n3. Dexterity (Low gravity)^n4. Agility (More speed)"); 
  
show_menu(idMENU_KEYSmenutext); 
 }
 else
 {
  
client_print(idprint_chat"You cant choose a skill you got 0skp");
 }
}
public 
choixMenu(idkey)
{
 switch(
key)
 {
  case 
0:
   
str(id) = str(id) + 1;
  case 
1:
   
def(id) = def(id) + 1;
  case 
2:
   
dex(id) = dex(id) + 1;
  case 
3:
   
agi(id) = agi(id) + 1;
 }
}
public 
clcmd_fullupdate() {
    return 
PLUGIN_HANDLED_MAIN
}
 
public 
event_restart_attempt() {
    new 
players[32], num
    get_players
(playersnum"a")
    for (new 
inum; ++i)
        
g_restart_attempt[players[i]] = true
}
 
public 
event_hud_reset(id) {
    if (
g_restart_attempt[id]) {
        
g_restart_attempt[id] = false
        
return
    }
    
event_player_spawn(id)
}
 
// this function is called on player spawn
public event_player_spawn(id) {
    
set_user_health(idskill_strenght 5)
    
set_user_armor(idskill_defence 10)
    
set_user_gravity(id800 skill_dexterity 50)
    
set_user_maxspeed(id100 skill_agility 5)



M249-M4A1 10-22-2007 06:01

Re: What worng ?
 
First, post your error(s) and problem. Secondly, I assume it is an error you are getting. You are doing skp(id). That's the problem. Below is how to solve it:

When you do new skp, you MUST do new skp[33]. This means skp can hold 33 entries (32 entries for the players + 1). When assigning an element of skp with the player's id, it works like this:

skp[id] = get_user_frags(id)


I would highly suggest you read this Pawn tutorial as it seems you have no background experience with arrays

elpouletorange 10-23-2007 17:41

Re: What worng ?
 
Thx. Do there is a tutorial in french because I can understand in english but it's more difficult...


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

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