Skocz do zawartości

Rekomendowane odpowiedzi

#include <sourcemod>

public Plugin myinfo =
{
	name = "x",
	author = "Marshall",
	description = "x",
	version = "x",
	url = "www.1shot2kill.pl"
};

public void OnPluginStart()
{
	RegConsoleCmd("sm_ruletka", Ruletka);
}

public Action Ruletka(int client, int args)
{
	char sbuffer[32];
	GetCmdArg(1, sbuffer, sizeof(sbuffer));

	int kasa_user = GetEntData(client, FindSendPropInfo("CCSPlayer", "m_iAccount"));
	int dolaryDodane = StringToInt(sbuffer);

	if(kasa_user < dolaryDodane)
	{
		PrintToChat(client, "★\x07 ★ 1Shot2kill.pl ★ \x05Masz tylko %i dolarów!", kasa_user);
		return Plugin_Handled;
	}

	if(args < 0)
	{
		PrintToChat(client, "★\x07 ★ 1Shot2kill.pl ★ \x05Wprowadziłeś niepoprwaną ilość gotówki. Try again.");
		return Plugin_Handled;
	}

	if(args == 0)
	{
		Handle menu = CreateMenu(RuletkaH);
		SetMenuTitle(menu, "Opis korzystania:\n- !ruletka <liczba_dolarów>\n- jeśli trafisz dosjtajesz 3 krotność gotówki bądź 2 krotność, zależy od szczęścia\n-Jeśli przegrałeś = tracisz");

		return Plugin_Handled;
	}

	int random = GetRandomInt(1, 7);
	int wygrana = dolaryDodane * 3;

	if(random == 1)
	{
		PrintToChat(client, "★ 1Shot2kill.pl ★ \x05Brawo, udało się! Wygrałeś \x04%i$\x05!", wygrana);
		SetEntData(client, FindSendPropInfo("CCSPlayer", "m_iAccount"), kasa_user+wygrana-dolaryDodane);

		if(kasa_user > 16000)
		{
			SetEntData(client, FindSendPropInfo("CCSPlayer", "m_iAccount"), 16000);
		}
	}
	else
	{
		PrintToChat(client, "★ 1Shot2kill.pl ★ \x05Niestety, nie udało się wygrać! Tracisz \x04%i$\x05!", dolaryDodane);
		SetEntData(client, FindSendPropInfo("CCSPlayer", "m_iAccount"), kasa_user-dolaryDodane);
	}

	return Plugin_Handled;
}

public int RuletkaH(Handle handle, MenuAction action, int client, int pos)
{
	if(action == MenuAction_Select)
	{
		char item[32];
		GetMenuItem(handle, pos, item, sizeof(item));

		if(StrEqual(item, "1"))
		{
			int random = GetRandomInt(1, 7);

			if(random == 1) PrintToChat(client, "★\x07 ★ 1Shot2kill.pl ★ \x05Wygrałbyś te losowanie, spróbuj teraz wpłacając dolary!");
			else PrintToChat(client, "★ 1Shot2kill.pl ★ \x05Masz szczęście, że to losowanie testowe! Przegrałbyś wpłacone dolary!");
		}
	}

	else if(action == MenuAction_End) CloseHandle(handle);
}

 

Odnośnik do komentarza
https://1shot2kill.pl/topic/35898-sm-przyk%C5%82ad-ruletki/
Udostępnij na innych stronach

Cytat

int kasa_user = GetEntData(client, FindSendPropInfo("CCSPlayer", "m_iAccount"));
Cytat

SetEntData(client, FindSendPropInfo("CCSPlayer", "m_iAccount"), kasa_user+wygrana-dolaryDodane);

 

Skąd to wytrzasnąłeś? I znowu mieszasz old syntax z new syntaxem co razi w oczy.

Czyżby copy&paste :D 

 

Wystarczy:

 

int PieniadzeGracza = GetEntProp(client, Prop_Send, "m_iAccount");
SetEntProp(client, Prop_Send, "m_iAccount", kasa_user+wygrana-dolaryDodane);

 

Odnośnik do komentarza
https://1shot2kill.pl/topic/35898-sm-przyk%C5%82ad-ruletki/#findComment-269600
Udostępnij na innych stronach

Gość
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...