Submodel in plugin
Hello guys, I have problem with plugin Footbal locker-room.
This plugin allows CT to select a soccer team for TT. Each team has its own model.
I have a problem because I can not do it to work with a submodel :(
I changed, I thought it worked. Actually gives models, but the next map I have crashed with Segmentation Fault. Something I did wrong.
Please make it work.
I make it like this. But errors and crashes
Code:
case 4: {
client_print(i, print_chat, "%s dostal stroj Wisly", wybrany);
cs_set_player_model(wybrany, "jbe_soccer3");
set_pev(wybrany, pev_body, 0);
set_pev(wybrany, pev_skin, 4);
This is orginal SMA. Work good, but dont have models
Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
enum Color
{
NORMAL = 1, // clients scr_concolor cvar color
GREEN, // Green Color
TEAM_COLOR, // Red, grey, blue
GREY, // grey
RED, // Red
BLUE, // Blue
}
new TeamName[][] =
{
"",
"TERRORIST",
"CT",
"SPECTATOR"
}
new gracz_id[33],wybrany;
new Player[32]
new const prefix[] = "^4[Turniej]"
public plugin_init()
{
register_plugin("TurniejJB", "1.0", "kIImIIzz");
register_clcmd("say /szatnia", "szatnia", ADMIN_BAN);
register_clcmd("say /kartka", "MainMenu", ADMIN_BAN)
register_clcmd("say /g", "gwizd", ADMIN_BAN)
}
public plugin_precache()
{
precache_model("models/player/arctic/arctic.mdl");
precache_model("models/player/terror/terror.mdl");
precache_model("models/player/guerilla/guerilla.mdl");
precache_model("models/player/leet/leet.mdl");
precache_model("models/player/terror/terror.mdl");
precache_model("models/player/vip/vip.mdl");
precache_model("models/player/sas/sas.mdl");
precache_model("models/player/gsg9/gsg9.mdl");
precache_model("models/player/gign/gign.mdl");
precache_sound("misc/gwizd.wav");
}
/////////szatnia////////////
public szatnia(id, level, cid) {
new menu = menu_create("Wybierz Typa:","menu_szatni");
for(new i=0, n=0; i<=32; i++)
{
if(!is_user_connected(i))
continue;
gracz_id[n++] = i;
new nazwa_gracza[64];
get_user_name(i, nazwa_gracza, 63)
menu_additem(menu, nazwa_gracza, "0", 0);
}
menu_setprop(menu, MPROP_BACKNAME, "Wroc");
menu_setprop(menu, MPROP_NEXTNAME, "Dalej");
menu_setprop(menu, MPROP_EXITNAME, "Wyjscie");
menu_display(id, menu);
return PLUGIN_HANDLED;
}
public menu_szatni(id, menus, item)
{
if (get_user_flags(id) & ADMIN_BAN)
{
wybrany = gracz_id[item];
new menus = menu_create("\rMenu Szatni", "wybieranie2")
menu_additem(menus, "Cracovia", "0", 0); // case 0
menu_additem(menus, "Lech", "1", 0); // case 1
menu_additem(menus, "Legia", "2", 0); // case 2
menu_additem(menus, "Lechia", "3", 0); // case 3
menu_additem(menus, "Wisla", "4", 0); // case 4
menu_additem(menus, "Gornik", "5", 0); // case 5
menu_additem(menus, "Podbeskidzie", "6", 0); // case 6
menu_additem(menus, "Bramkarz1", "7", 0); // case 7
menu_additem(menus, "Bramkarz2", "8", 0); // case 8
menu_setprop(menus, MPROP_EXIT, MEXIT_ALL)
menu_display(id, menus, 0)
}
else
{
client_print(id, print_chat, "Nie masz do tego dostepu Koniu!")
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED;
}
public wybieranie2(id, menus, item)
for(new i=0, n=0; i<=32; i++)
{
if (item == MENU_EXIT)
{
menu_destroy(menus)
return PLUGIN_HANDLED
}
new data[6], iName[64]
new acces, callback
menu_item_getinfo(menus, item, acces, data,5, iName, 63, callback)
new key = str_to_num(data)
switch(key)
{
case 0: {
client_print(i, print_chat, "%s dostal stroj Cracovi", wybrany);
cs_set_user_model(wybrany, "arctic");
}
case 1: {
client_print(i, print_chat, "%s dostal stroj Lecha", wybrany);
cs_set_user_model(wybrany, "guerilla");
}
case 2: {
client_print(i, print_chat, "%s dostal stroj Legi", wybrany);
cs_set_user_model(wybrany, "leet");
}
case 3: {
client_print(i, print_chat, "%s dostal stroj Lechi", wybrany);
cs_set_user_model(wybrany, "terror");
}
case 4: {
client_print(i, print_chat, "%s dostal stroj Wisly", wybrany);
cs_set_user_model(wybrany, "urban");
}
case 5: {
client_print(i, print_chat, "%s dostal stroj Gornika", wybrany);
cs_set_user_model(wybrany, "vip");
}
case 6: {
client_print(i, print_chat, "%s dostal stroj Podbeskidzia", wybrany);
cs_set_user_model(wybrany, "sas");
}
case 7: {
client_print(i, print_chat, "%s dostal stroj Bramkarza1", wybrany);
cs_set_user_model(wybrany, "gign");
}
case 8: {
client_print(i, print_chat, "%s dostal stroj Bramkarza2", wybrany);
cs_set_user_model(wybrany, "gsg9");
}
}
menu_destroy(menus)
return PLUGIN_HANDLED
}
/////////////////kartki/////////////////////
public MainMenu(iPlayer)
{
if (is_user_alive(iPlayer) && cs_get_user_team(iPlayer) & CS_TEAM_CT)
{
new menu = menu_create("\rMenu kartek", "MainMenu_Handle")
new players[32], pnum, key
new szName[32], szName2[10]
get_players(players, pnum, "a")
for(new i; i < pnum; i++)
{
key = players[i]
if (cs_get_user_team(key) != CS_TEAM_T)
{
continue
}
get_user_name(key, szName, 31)
num_to_str(key, szName2, 9)
menu_additem(menu, szName, szName2, 0)
}
menu_display(iPlayer, menu)
return PLUGIN_HANDLED
}
else ColorChat(iPlayer, GREY, "%s Tylko zyjacy Straznik moze uzyc tego menu!", prefix)
return PLUGIN_HANDLED
}
public MainMenu_Handle(iPlayer, menu, item)
{
if( item == MENU_EXIT )
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new data[6], iName[64]
new access, callback
menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)
Player[iPlayer] = str_to_num(data)
ColorMenu(iPlayer)
return PLUGIN_HANDLED
}
public ColorMenu(iPlayer)
{
new sub = menu_create("\rMenu Poswiaty^n\wWybierz kolor:", "ColorMenu_Handle")
menu_additem(sub, "\rCzerwona", "1", 0)
menu_additem(sub, "\yZolta", "2", 0)
menu_setprop(sub, MPROP_EXIT, MEXIT_ALL)
menu_display(iPlayer, sub)
}
public ColorMenu_Handle(iPlayer, sub, item)
{
if (item == MENU_EXIT)
{
menu_destroy(sub)
return PLUGIN_HANDLED
}
new Data[7], Name[64]
new Access, Callback
menu_item_getinfo(sub, item, Access, Data,5, Name, 63, Callback)
new key = str_to_num(Data)
get_user_name(Player[iPlayer], Name, sizeof(Name) -1)
switch (key)
{
case 1:
{
set_user_rendering(Player[iPlayer], kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 40)
ColorChat(0, GREY, "%s %s dostal teraz ^4Czerwona Kartke^3!", prefix, Name )
}
case 2:
{
set_user_rendering(Player[iPlayer], kRenderFxGlowShell, 255, 255, 0, kRenderNormal, 40)
ColorChat(0, GREY, "%s %s dostal teraz ^4Zolta Kartke^3!", prefix, Name )
}
}
return PLUGIN_HANDLED
}
ColorChat(id, Color:type, const msg[], {Float,Sql,Result,_}:...)
{
static message[256];
switch(type)
{
case NORMAL: // clients scr_concolor cvar color
{
message[0] = 0x01;
}
case GREEN: // Green
{
message[0] = 0x04;
}
default: // White, Red, Blue
{
message[0] = 0x03;
}
}
vformat(message[1], 251, msg, 4);
// Make sure message is not longer than 192 character. Will crash the server.
message[192] = '^0';
static team, ColorChange, index, MSG_Type;
if(id)
{
MSG_Type = MSG_ONE;
index = id;
} else {
index = FindPlayer();
MSG_Type = MSG_ALL;
}
team = get_user_team(index);
ColorChange = ColorSelection(index, MSG_Type, type);
ShowColorMessage(index, MSG_Type, message);
if(ColorChange)
{
Team_Info(index, MSG_Type, TeamName[team]);
}
}
ShowColorMessage(id, type, message[])
{
message_begin(type, get_user_msgid("SayText"), _, id);
write_byte(id)
write_string(message);
message_end();
}
Team_Info(id, type, team[])
{
message_begin(type, get_user_msgid("TeamInfo"), _, id);
write_byte(id);
write_string(team);
message_end();
return 1;
}
ColorSelection(index, type, Color:Type)
{
switch(Type)
{
case RED:
{
return Team_Info(index, type, TeamName[1]);
}
case BLUE:
{
return Team_Info(index, type, TeamName[2]);
}
case GREY:
{
return Team_Info(index, type, TeamName[0]);
}
}
return 0;
}
FindPlayer()
{
static i;
i = -1;
while(i <= get_maxplayers())
{
if(is_user_connected(++i))
{
return i;
}
}
return -1;
}
public gwizd(id)
{
emit_sound(0, CHAN_AUTO, "misc/gwizd.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1045\\ f0\\ fs16 \n\\ par }
*/
This is what i do. Crash. Errors
Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <fakemeta>
#include <jailbreak>
#include <amxmisc>
#include <xs>
#define USAGE_LEVEL ADMIN_KICK
native cs_set_player_model(id, newmodel[]); //wymaga cs_player_models_api.amxx
enum Color
{
NORMAL = 1, // clients scr_concolor cvar color
GREEN, // Green Color
TEAM_COLOR, // Red, grey, blue
GREY, // grey
RED, // Red
BLUE, // Blue
}
new TeamName[][] =
{
"",
"TERRORIST",
"CT",
"SPECTATOR"
}
new gracz_id[33],wybrany;
new Player[32]
new const prefix[] = "^4[Turniej]"
public plugin_init()
{
register_plugin("TurniejJB", "1.0", "kIImIIzz");
register_clcmd("say /szatnia", "szatnia");
register_clcmd("say /kartka", "MainMenu");
register_clcmd("say /g", "gwizd");
register_clcmd("say /gk", "gwizdk");
}
public plugin_precache()
{
precache_model("models/player/jbe_soccer3/jbe_soccer3.mdl");
precache_sound("misc/gwizdstart.wav");
precache_sound("misc/gwizdkoniec.wav");
}
/////////szatnia////////////
public szatnia(id, level, cid) {
new menu = menu_create("Wybierz Typa:","menu_szatni");
for(new i=0, n=0; i<=32; i++)
{
if(!is_user_connected(i))
continue;
gracz_id[n++] = i;
new nazwa_gracza[64];
get_user_name(i, nazwa_gracza, 63)
menu_additem(menu, nazwa_gracza, "0", 0);
}
menu_setprop(menu, MPROP_BACKNAME, "Wroc");
menu_setprop(menu, MPROP_NEXTNAME, "Dalej");
menu_setprop(menu, MPROP_EXITNAME, "Wyjscie");
menu_display(id, menu);
return PLUGIN_HANDLED;
}
public menu_szatni(id, menus, item)
{
if(jail_get_prowadzacy() == id) // Tylko admin badz CT
{
wybrany = gracz_id[item];
new menus = menu_create("\rMenu Szatni", "wybieranie2")
menu_additem(menus, "Cracovia", "0", 0); // case 0
menu_additem(menus, "Lech", "1", 0); // case 1
menu_additem(menus, "Legia", "2", 0); // case 2
menu_additem(menus, "Lechia", "3", 0); // case 3
menu_additem(menus, "Wisla", "4", 0); // case 4
menu_additem(menus, "Gornik", "5", 0); // case 5
menu_additem(menus, "Podbeskidzie", "6", 0); // case 6
menu_additem(menus, "Bramkarz1", "7", 0); // case 7
menu_additem(menus, "Bramkarz2", "8", 0); // case 8
menu_setprop(menus, MPROP_EXIT, MEXIT_ALL)
menu_display(id, menus, 0)
}
else
{
client_print(id, print_chat, "Nie masz do tego dostepu Koniu!")
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED;
}
public wybieranie2(id, menus, item)
for(new i=0, n=0; i<=32; i++)
{
if (item == MENU_EXIT)
{
menu_destroy(menus)
return PLUGIN_HANDLED
}
new data[6], iName[64]
new acces, callback
menu_item_getinfo(menus, item, acces, data,5, iName, 63, callback)
new key = str_to_num(data)
switch(key)
{
case 0: {
client_print(i, print_chat, "%s dostal stroj Cracovi", wybrany);
cs_set_player_model(wybrany, "jbe_soccer3");
set_pev(wybrany, pev_body, 0);
set_pev(wybrany, pev_skin, 0);
}
case 1: {
client_print(i, print_chat, "%s dostal stroj Lecha", wybrany);
cs_set_player_model(wybrany, "jbe_soccer3");
set_pev(wybrany, pev_body, 0);
set_pev(wybrany, pev_skin, 1);
}
case 2: {
client_print(i, print_chat, "%s dostal stroj Legi", wybrany);
cs_set_player_model(wybrany, "jbe_soccer3");
set_pev(wybrany, pev_body, 0);
set_pev(wybrany, pev_skin, 2);
}
case 3: {
client_print(i, print_chat, "%s dostal stroj Lechi", wybrany);
cs_set_player_model(wybrany, "jbe_soccer3");
set_pev(wybrany, pev_body, 0);
set_pev(wybrany, pev_skin, 3);
}
case 4: {
client_print(i, print_chat, "%s dostal stroj Wisly", wybrany);
cs_set_player_model(wybrany, "jbe_soccer3");
set_pev(wybrany, pev_body, 0);
set_pev(wybrany, pev_skin, 4);
}
case 5: {
client_print(i, print_chat, "%s dostal stroj Gornika", wybrany);
cs_set_player_model(wybrany, "jbe_soccer3");
set_pev(wybrany, pev_body, 0);
set_pev(wybrany, pev_skin, 5);
}
case 6: {
client_print(i, print_chat, "%s dostal stroj Podbeskidzia", wybrany);
cs_set_player_model(wybrany, "jbe_soccer3");
set_pev(wybrany, pev_body, 0);
set_pev(wybrany, pev_skin, 6);
}
case 7: {
client_print(i, print_chat, "%s dostal stroj Bramkarza1", wybrany);
cs_set_player_model(wybrany, "jbe_soccer3");
set_pev(wybrany, pev_body, 1);
set_pev(wybrany, pev_skin, 2);
}
case 8: {
client_print(i, print_chat, "%s dostal stroj Bramkarza2", wybrany);
cs_set_player_model(wybrany, "jbe_soccer3");
set_pev(wybrany, pev_body, 1);
set_pev(wybrany, pev_skin, 3);
}
}
menu_destroy(menus)
return PLUGIN_HANDLED
}
/////////////////kartki/////////////////////
public MainMenu(iPlayer)
{
if (is_user_alive(iPlayer) && cs_get_user_team(iPlayer) & CS_TEAM_CT)
{
new menu = menu_create("\rMenu kartek", "MainMenu_Handle")
new players[32], pnum, key
new szName[32], szName2[10]
get_players(players, pnum, "a")
for(new i; i < pnum; i++)
{
key = players[i]
if (cs_get_user_team(key) != CS_TEAM_T)
{
continue
}
get_user_name(key, szName, 31)
num_to_str(key, szName2, 9)
menu_additem(menu, szName, szName2, 0)
}
menu_display(iPlayer, menu)
return PLUGIN_HANDLED
}
else ColorChat(iPlayer, GREY, "%s Tylko zyjacy Straznik moze uzyc tego menu!", prefix)
return PLUGIN_HANDLED
}
public MainMenu_Handle(iPlayer, menu, item)
{
if( item == MENU_EXIT )
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new data[6], iName[64]
new access, callback
menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)
Player[iPlayer] = str_to_num(data)
ColorMenu(iPlayer)
return PLUGIN_HANDLED
}
public ColorMenu(iPlayer)
{
new sub = menu_create("\rMenu Poswiaty^n\wWybierz kolor:", "ColorMenu_Handle")
menu_additem(sub, "\rCzerwona", "1", 0)
menu_additem(sub, "\yZolta", "2", 0)
menu_setprop(sub, MPROP_EXIT, MEXIT_ALL)
menu_display(iPlayer, sub)
}
public ColorMenu_Handle(iPlayer, sub, item)
{
if (item == MENU_EXIT)
{
menu_destroy(sub)
return PLUGIN_HANDLED
}
new Data[7], Name[64]
new Access, Callback
menu_item_getinfo(sub, item, Access, Data,5, Name, 63, Callback)
new key = str_to_num(Data)
get_user_name(Player[iPlayer], Name, sizeof(Name) -1)
switch (key)
{
case 1:
{
set_user_rendering(Player[iPlayer], kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 40)
ColorChat(0, GREY, "%s %s dostal teraz ^4Czerwona Kartke^3!", prefix, Name )
}
case 2:
{
set_user_rendering(Player[iPlayer], kRenderFxGlowShell, 255, 255, 0, kRenderNormal, 40)
ColorChat(0, GREY, "%s %s dostal teraz ^4Zolta Kartke^3!", prefix, Name )
}
}
return PLUGIN_HANDLED
}
ColorChat(id, Color:type, const msg[], {Float,Sql,Result,_}:...)
{
static message[256];
switch(type)
{
case NORMAL: // clients scr_concolor cvar color
{
message[0] = 0x01;
}
case GREEN: // Green
{
message[0] = 0x04;
}
default: // White, Red, Blue
{
message[0] = 0x03;
}
}
vformat(message[1], 251, msg, 4);
// Make sure message is not longer than 192 character. Will crash the server.
message[192] = '^0';
static team, ColorChange, index, MSG_Type;
if(id)
{
MSG_Type = MSG_ONE;
index = id;
} else {
index = FindPlayer();
MSG_Type = MSG_ALL;
}
team = get_user_team(index);
ColorChange = ColorSelection(index, MSG_Type, type);
ShowColorMessage(index, MSG_Type, message);
if(ColorChange)
{
Team_Info(index, MSG_Type, TeamName[team]);
}
}
ShowColorMessage(id, type, message[])
{
message_begin(type, get_user_msgid("SayText"), _, id);
write_byte(id)
write_string(message);
message_end();
}
Team_Info(id, type, team[])
{
message_begin(type, get_user_msgid("TeamInfo"), _, id);
write_byte(id);
write_string(team);
message_end();
return 1;
}
ColorSelection(index, type, Color:Type)
{
switch(Type)
{
case RED:
{
return Team_Info(index, type, TeamName[1]);
}
case BLUE:
{
return Team_Info(index, type, TeamName[2]);
}
case GREY:
{
return Team_Info(index, type, TeamName[0]);
}
}
return 0;
}
FindPlayer()
{
static i;
i = -1;
while(i <= get_maxplayers())
{
if(is_user_connected(++i))
{
return i;
}
}
return -1;
}
public gwizd(id)
{
emit_sound(0, CHAN_AUTO, "misc/gwizdstart.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
}
public gwizdk(id)
{
emit_sound(0, CHAN_AUTO, "misc/gwizdkoniec.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1045\\ f0\\ fs16 \n\\ par }
*/
http://www120.zippyshare.com/v/lw0Rfrqz/file.html
|