Problem z losowaniem
Kaskader
15.01.2010
Witajcie. Napisałem sobie plugin, lecz mam pewien problem. Po wpisaniu na sayu /kupon nie daje mi nic i wyskakuje wiadomość, że nie mam tyle kasy chociaż potrzebne jest tylko 400 a miałem ponad 16 tysięcy.
Oto kod:
Proszę o szybką pomoc.
Oto kod:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#define PLUGIN "Kupon"
#define VERSION "1.0"
#define AUTHOR "Koksik"
new plugin_on
new gravity_on
new speed_on
new noclip_on
new elite_on
new health_on
new kill_on
new money_on
new price
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
register_clcmd("say /kupon", "kupon");
plugin_on = register_cvar("amx_kupon_plugin", "1") ;
price = register_cvar("amx_kupon_price", "400") ;
gravity_on = register_cvar("amx_gravity_on", "1") ;
speed_on = register_cvar("amx_speed_on", "1") ;
noclip_on = register_cvar("amx_noclip_on", "1") ;
elite_on = register_cvar("amx_elite_on", "1") ;
health_on = register_cvar("amx_health_on", "1") ;
kill_on = register_cvar("amx_kill_on", "1") ;
money_on = register_cvar("amx_money_on", "1") ;
set_task(30.0, "printer", _, _, _, "b");
}
public kupon(id)
{
new kasa = cs_get_user_money(id)
new zycie = get_user_health(id)
new alajf = is_user_alive(id)
if(kasa < price){
client_print(id, print_chat, "Nie masz kasy, nie losujesz.", price)
}
if(!alajf){
cs_set_user_money(id, kasa - 500)
client_print(id, print_chat, "Nie zyjesz, wiec nie badz taki sprytny. Komenda off. -500 $ Za probe.")
}
if(alajf && plugin_on == 1 && kasa >= price)
{
new rand = random_num(0,6)
switch(rand)
{
case 0: {
if (gravity_on == 1)
{
cs_set_user_money(id, kasa - price)
set_user_gravity(id, 0.50)
client_print(id, print_chat, "Otrzymujesz Grawitacje! Gratulacje.") ;
}
else kupon(id)
}
case 1: {
if(elite_on)
{
cs_set_user_money(id, kasa - price)
give_item(id, "weapon_elite")
give_item(id, "ammo_9mm")
client_print(id, print_chat, "Otrzymujesz Dual Elite's. Gratulacje.") ;
}
else kupon(id)
}
case 2: {
if (money_on == 1)
{
cs_set_user_money(id, kasa - price)
cs_set_user_money(id, kasa + 6000)
client_print(id, print_chat, "Wygrales 6000 $. Gratulacje.") ;
}
else kupon(id)
}
case 3: {
if (noclip_on == 1)
{
cs_set_user_money(id, kasa - price)
set_user_noclip(id, 1)
client_print(id, print_chat, "Otrzymujesz Noclip! Gratulacje.") ;
}
else kupon(id)
}
case 4: {
if (health_on == 1)
{
cs_set_user_money(id, kasa - price)
set_user_health(id, zycie + 50)
client_print(id, print_chat, "Otrzymujesz 50 HP. Gratulacje.") ;
}
else kupon(id)
}
case 5: {
if (kill_on == 1)
{
cs_set_user_money(id, kasa - price)
client_cmd(id, "kill", 0)
client_print(id, print_chat, "Popelniles samobojstwo... Najwyrazniej miales problemy...") ;
}
else kupon(id)
}
case 6: {
if (speed_on == 1)
{
set_user_maxspeed(id, 30.0);
client_print(id, print_chat, "Starosc nie radosc.") ;
cs_set_user_money(id, kasa - price)
}
else kupon(id)
}
}
client_print(id, print_chat, "Losujesz nie pozalujesz. Cena: %s $",price)
}
}
public printer()
{
client_print(0, print_chat, "Chcesz losowac i wygrywac wpisz: say /kupon.")
client_print(0, print_chat, "[Kupon] Zyczymy szczescia w losowaniu.")
}
Proszę o szybką pomoc.
Kaskader
16.01.2010
Teraz po wpisaniu w sayu /konkurs nic się nie wyświetla anie nie dzieje.
Miczu
16.01.2010
if(alajf && plugin_on == 1 && kasa >= price)Tu tez musisz poprawiec

A mowiac dokladniej kazdy "price"
Kaskader
16.01.2010
A mógłbyś powiedzieć mi jak dokładnie, bo te price miałem inaczej zrobione ale gościu jeden mówił, że to od tego i, że musi być tak jak teraz w kodzie. Będę bardzo wdzięczny.
DarkGL
17.01.2010
wszystkie price zmieniasz na
Użytkownik DarkGL edytował ten post 17.01.2010 10:19
get_pcvar_num(price)
Użytkownik DarkGL edytował ten post 17.01.2010 10:19
Kaskader
17.01.2010
Tak miałem na początku, lecz kazał gościu to zmienić, bo przy kompilacji byłby errory.
Teraz kod wygląda tak, bo trochę zmieniłem:
Ale są błędy przy kompilacji:
/home/groups/amxmodx/tmp3/phpuufXXZ.sma(43) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpuufXXZ.sma(47) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpuufXXZ.sma(122) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpuufXXZ.sma(123) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpuufXXZ.sma(124) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpuufXXZ.sma(135) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/phpuufXXZ.sma(135) : error 017: undefined symbol "printer"
/home/groups/amxmodx/tmp3/phpuufXXZ.sma(140) : warning 209: function "kupon" should return a value
2 Errors.
Could not locate output file /home/groups/amxmodx/public_html/websc3/phpuufXXZ.amx (compile failed).
Użytkownik Kaskader edytował ten post 17.01.2010 15:59
Teraz kod wygląda tak, bo trochę zmieniłem:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#define PLUGIN "Kupon"
#define VERSION "1.0"
#define AUTHOR "Koksik"
new plugin_on
new gravity_on
new speed_on
new noclip_on
new elite_on
new health_on
new kill_on
new money_on
new price
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
register_clcmd("say /kupon", "kupon");
plugin_on = register_cvar("amx_kupon_plugin", "1") ;
price = register_cvar("amx_kupon_price", "400") ;
gravity_on = register_cvar("amx_gravity_on", "1") ;
speed_on = register_cvar("amx_speed_on", "1") ;
noclip_on = register_cvar("amx_noclip_on", "1") ;
elite_on = register_cvar("amx_elite_on", "1") ;
health_on = register_cvar("amx_health_on", "1") ;
kill_on = register_cvar("amx_kill_on", "1") ;
money_on = register_cvar("amx_money_on", "1") ;
set_task(30.0, "printer", _, _, _, "b");
}
public kupon(id)
{
if(plugin_on == 1)
{
new kasa = cs_get_user_money(id)
new zycie = get_user_health(id)
if(kasa < get_pcvar_num(price) )
{
client_print(id, print_chat, "Nie masz kasy, nie losujesz.", get_pcvar_num(price))
}
if(!is_user_alive(id)){
cs_set_user_money(id, kasa - 500)
client_print(id, print_chat, "Nie zyjesz, wiec nie badz taki sprytny. Komenda off. -500 $ Za probe.")
}
if(is_user_alive(id) )
{
new rand = random_num(0,6)
switch(rand)
{
case 0: {
if (gravity_on == 1)
{
cs_set_user_money(id, kasa -get_pcvar_num(price) )
set_user_gravity(id, 0.50)
client_print(id, print_chat, "Otrzymujesz Grawitacje! Gratulacje.") ;
}
else kupon(id)
}
case 1: {
if(elite_on)
{
cs_set_user_money(id, kasa - get_pcvar_num(price))
give_item(id, "weapon_elite")
give_item(id, "ammo_9mm")
client_print(id, print_chat, "Otrzymujesz Dual Elite's. Gratulacje.") ;
}
else kupon(id)
}
case 2: {
if (money_on == 1)
{
cs_set_user_money(id, kasa - get_pcvar_num(price))
cs_set_user_money(id, kasa + 6000)
client_print(id, print_chat, "Wygrales 6000 $. Gratulacje.") ;
}
else kupon(id)
}
case 3: {
if (noclip_on == 1)
{
cs_set_user_money(id, kasa - get_pcvar_num(price))
set_user_noclip(id, 1)
client_print(id, print_chat, "Otrzymujesz Noclip! Gratulacje.") ;
}
else kupon(id)
}
case 4: {
if (health_on == 1)
{
cs_set_user_money(id, kasa - get_pcvar_num(price))
set_user_health(id, zycie + 50)
client_print(id, print_chat, "Otrzymujesz 50 HP. Gratulacje.") ;
}
else kupon(id)
}
case 5: {
if (kill_on == 1)
{
cs_set_user_money(id, kasa - get_pcvar_num(price))
client_cmd(id, "kill", 0)
client_print(id, print_chat, "Popelniles samobojstwo... Najwyrazniej miales problemy...") ;
}
else kupon(id)
}
case 6: {
if (speed_on == 1)
{
cs_set_user_money(id, kasa - get_pcvar_num(price))
set_user_maxspeed(id, 30.0)
client_print(id, print_chat, "Starosc nie radosc.") ;
return PLUGIN_HANDLED
}
else kupon(id)
}
}
client_print(id, print_chat, "Losujesz nie pozalujesz. Cena: %s $",get_pcvar_num(price))
}
}
public printer()
{
client_print(0, print_chat, "Chcesz losowac i wygrywac wpisz: say /kupon.")
client_print(0, print_chat, "[Kupon] Zyczymy szczescia w losowaniu.")
}
}
Ale są błędy przy kompilacji:
/home/groups/amxmodx/tmp3/phpuufXXZ.sma(43) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpuufXXZ.sma(47) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpuufXXZ.sma(122) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpuufXXZ.sma(123) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpuufXXZ.sma(124) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpuufXXZ.sma(135) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/phpuufXXZ.sma(135) : error 017: undefined symbol "printer"
/home/groups/amxmodx/tmp3/phpuufXXZ.sma(140) : warning 209: function "kupon" should return a value
2 Errors.
Could not locate output file /home/groups/amxmodx/public_html/websc3/phpuufXXZ.amx (compile failed).
Użytkownik Kaskader edytował ten post 17.01.2010 15:59
DarkGL
17.01.2010
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> #define PLUGIN "Kupon" #define VERSION "1.0" #define AUTHOR "Koksik" new plugin_on new gravity_on new speed_on new noclip_on new elite_on new health_on new kill_on new money_on new price public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR); register_clcmd("say /kupon", "kupon"); plugin_on = register_cvar("amx_kupon_plugin", "1") ; price = register_cvar("amx_kupon_price", "400") ; gravity_on = register_cvar("amx_gravity_on", "1") ; speed_on = register_cvar("amx_speed_on", "1") ; noclip_on = register_cvar("amx_noclip_on", "1") ; elite_on = register_cvar("amx_elite_on", "1") ; health_on = register_cvar("amx_health_on", "1") ; kill_on = register_cvar("amx_kill_on", "1") ; money_on = register_cvar("amx_money_on", "1") ; set_task(30.0, "printer", _, _, _, "b"); } public kupon(id){ if(plugin_on == 1) { new kasa = cs_get_user_money(id) new zycie = get_user_health(id) if(kasa < get_pcvar_num(price) ) { client_print(id, print_chat, "Nie masz kasy, nie losujesz.", get_pcvar_num(price)) } if(!is_user_alive(id)){ cs_set_user_money(id, kasa - 500) client_print(id, print_chat, "Nie zyjesz, wiec nie badz taki sprytny. Komenda off. -500 $ Za probe.") } if(is_user_alive(id) ) { new rand = random_num(0,6) switch(rand) { case 0: { if (gravity_on == 1) { cs_set_user_money(id, kasa -get_pcvar_num(price) ) set_user_gravity(id, 0.50) client_print(id, print_chat, "Otrzymujesz Grawitacje! Gratulacje.") ; } else kupon(id) } case 1: { if(elite_on) { cs_set_user_money(id, kasa - get_pcvar_num(price)) give_item(id, "weapon_elite") give_item(id, "ammo_9mm") client_print(id, print_chat, "Otrzymujesz Dual Elite's. Gratulacje.") ; } else kupon(id) } case 2: { if (money_on == 1) { cs_set_user_money(id, kasa - get_pcvar_num(price)) cs_set_user_money(id, kasa + 6000) client_print(id, print_chat, "Wygrales 6000 $. Gratulacje.") ; } else kupon(id) } case 3: { if (noclip_on == 1) { cs_set_user_money(id, kasa - get_pcvar_num(price)) set_user_noclip(id, 1) client_print(id, print_chat, "Otrzymujesz Noclip! Gratulacje.") ; } else kupon(id) } case 4: { if (health_on == 1) { cs_set_user_money(id, kasa - get_pcvar_num(price)) set_user_health(id, zycie + 50) client_print(id, print_chat, "Otrzymujesz 50 HP. Gratulacje.") ; } else kupon(id) } case 5: { if (kill_on == 1) { cs_set_user_money(id, kasa - get_pcvar_num(price)) client_cmd(id, "kill", 0) client_print(id, print_chat, "Popelniles samobojstwo... Najwyrazniej miales problemy...") ; } else kupon(id) } case 6: { if (speed_on == 1) { cs_set_user_money(id, kasa - get_pcvar_num(price)) set_user_maxspeed(id, 30.0) client_print(id, print_chat, "Starosc nie radosc.") ; return PLUGIN_HANDLED } else kupon(id) } } client_print(id, print_chat, "Losujesz nie pozalujesz. Cena: %s $",get_pcvar_num(price)) } } return PLUGIN_HANDLED; }
Kaskader
21.01.2010
Przepraszam, ale nie zrozumiałem twojej wypowiedz. Wiesz dopiero zaczynam i jestem wdzięczny, że ktoś mi pomaga.
DarkGL
21.01.2010
Więc tak R3X pokazał ci gdzie masz błąd
zamaist
if(kasa < price) na if(kasa < get_pcvar_num(price))zauważ że w pluginie wszędzie popełniasz ten sam błąd
zamaist
get_pcvar_num(jakis_cvar)masz
jakiś cvartzn. zamiast
if(elite_on)powinno być
if(get_pcvar_num(elite_on) == 1)
Kaskader
23.01.2010
Aha, dzięki sprawdzę to czy działa i edytuje posta. A właśnie zastanawiałem się, czy tam nie powinno być get_pcvar_num 
Oto przerobione sma:
A to błędy przy kompilacji:

Oto przerobione sma:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#define PLUGIN "Kupon"
#define VERSION "1.0"
#define AUTHOR "Koksik"
new plugin_on
new gravity_on
new speed_on
new noclip_on
new elite_on
new health_on
new kill_on
new money_on
new price
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
register_clcmd("say /kupon", "kupon");
plugin_on = register_cvar("amx_kupon_plugin", "1") ;
price = register_cvar("amx_kupon_price", "400") ;
gravity_on = register_cvar("amx_gravity_on", "1") ;
speed_on = register_cvar("amx_speed_on", "1") ;
noclip_on = register_cvar("amx_noclip_on", "1") ;
elite_on = register_cvar("amx_elite_on", "1") ;
health_on = register_cvar("amx_health_on", "1") ;
kill_on = register_cvar("amx_kill_on", "1") ;
money_on = register_cvar("amx_money_on", "1") ;
set_task(30.0, "printer", _, _, _, "b");
}
public kupon(id){
if(get_pcvar_num(plugin_on) == 1)
{
new kasa = cs_get_user_money(id)
new zycie = get_user_health(id)
if(kasa < get_pcvar_num(price) )
{
client_print(id, print_chat, "Nie masz kasy, nie losujesz.", get_pcvar_num(price))
}
if(!is_user_alive(id)){
cs_set_user_money(id, kasa - 500)
client_print(id, print_chat, "Nie zyjesz, wiec nie badz taki sprytny. Komenda off. -500 $ Za probe.")
}
if(is_user_alive(id) )
{
new rand = random_num(0,6)
switch(rand)
{
case 0: {
if (get_pcvar_num(gravity_on) == 1)
{
cs_set_user_money(id, kasa -get_pcvar_num(price) )
set_user_gravity(id, 0.50)
client_print(id, print_chat, "Otrzymujesz Grawitacje! Gratulacje.") ;
}
else kupon(id)
}
case 1: {
if(get_pcvar_num(elite_on) == 1 )
{
cs_set_user_money(id, kasa - get_pcvar_num(price))
give_item(id, "weapon_elite")
give_item(id, "ammo_9mm")
client_print(id, print_chat, "Otrzymujesz Dual Elite's. Gratulacje.") ;
}
else kupon(id)
}
case 2: {
if (get_pcvar_num(money_on) == 1)
{
cs_set_user_money(id, kasa - get_pcvar_num(price))
cs_set_user_money(id, kasa + 6000)
client_print(id, print_chat, "Wygrales 6000 $. Gratulacje.") ;
}
else kupon(id)
}
case 3: {
if (get_pcvar_num(noclip_on) == 1)
{
cs_set_user_money(id, kasa - get_pcvar_num(price))
set_user_noclip(id, 1)
client_print(id, print_chat, "Otrzymujesz Noclip! Gratulacje.") ;
}
else kupon(id)
}
case 4: {
if (get_pcvar_num(health_on) == 1)
{
cs_set_user_money(id, kasa - get_pcvar_num(price))
set_user_health(id, zycie + 50)
client_print(id, print_chat, "Otrzymujesz 50 HP. Gratulacje.") ;
}
else kupon(id)
}
case 5: {
if (get_pcvar_num(kill_on) == 1)
{
cs_set_user_money(id, kasa - get_pcvar_num(price))
client_cmd(id, "kill", 0)
client_print(id, print_chat, "Popelniles samobojstwo... Najwyrazniej miales problemy...") ;
}
else kupon(id)
}
case 6: {
if (get_pcvar_num(speed_on) == 1)
{
cs_set_user_money(id, kasa - get_pcvar_num(price))
set_user_maxspeed(id, 30.0)
client_print(id, print_chat, "Starosc nie radosc.") ;
return PLUGIN_HANDLED
}
else kupon(id)
}
}
client_print(id, print_chat, "Losujesz nie pozalujesz. Cena: %s $",get_pcvar_num(price))
}
}
return PLUGIN_HANDLED;
}
A to błędy przy kompilacji:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright © 1997-2006 ITB CompuPhase, AMX Mod X Team
/home/groups/amxmodx/compiler3/core(0) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(5) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(6) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(7) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(8) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(9) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(10) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(11) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(12) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(13) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(14) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(15) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(17) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(18) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(19) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(20) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(21) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(22) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(23) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(24) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(25) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(26) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(27) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(28) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(29) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/compiler3/core(30) : error 075: input line too long (after substitutions)
Compilation aborted.
26 Errors.
DarkGL
23.01.2010
Welcome to the AMX Mod X 1.76-300 Compiler. Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team Header size: 560 bytes Code size: 3832 bytes Data size: 2432 bytes Stack/heap size: 16384 bytes; max. usage is unknown, due to recursion Total requirements: 23208 bytes Done.
żądnych problemów
Kaskader
04.02.2010
Wszystko niby spoko. Dostaję przedmiot, ale nie pokazuje w sayu wartości cvara.
Owner123
04.02.2010
Cena: %sNie pokazuje bo użyłeś "s", co jest znacznikiem stringa. Zamień to na "i" i będzie działać.