Jump to content

návod Ammo shop systém


kjn

Recommended Posts

Zdravím, tak ma napadlo sa podeliť o môj prvý ammo shop pokial ma ešte teší že som ho vytvoril s pomocou wiki.

 

Na začiatok:

new ammo;

Druhá fáza je vytvoriť pickup v amme

////////////ammonation
    ammo = CreatePickup(1254, 19, 312.4347,-165.6759,999.6010);

NOTE: 1254 je síce vesta ale mne sa to páči, je to netradičné a nevidno to nejak často na serveroch.

 

Tretia fáza je OnPlayerPickUpPickup

public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == ammo)//ammo - zbrane
    {
 		ShowPlayerDialog(playerid, 111, DIALOG_STYLE_LIST, "StuntPark Ammonation", "Health $2,000\nArmour $2,000\nDesert Eagle $500\nSawnoff Shotgun $1,000\nMP5 $1,500\nAK-47 $4,000\nM4 $4,000\nSniper Rifle $3,500\nGranade $3,000", "Buy", "Exit");

     return 1;
    }

Stvrtá fáza je dialog sám o sebe
 
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
		if(dialogid == 111) // Color Settings
		{
			if(!response) return SendClientMessage(playerid, 0xFFFFFFAA, "Odišiel si.");
			switch(listitem)
			{
		        case 0: // Zivot
		        {
		                if(GetPlayerMoney(playerid) < 2000) return SendClientMessage(playerid, 0xFFFFFF, "{C0C0C0}Nemáš dostatok penazí.");
        	        	GivePlayerMoney(playerid, -2000);
        	        	SetPlayerHealth(playerid, 100);

						return 1;
				}
	   			case 1: // vesta
		        {
	                        if(GetPlayerMoney(playerid) < 2000) return SendClientMessage(playerid, 0xFFFFFF, "{C0C0C0}Nemáš dostatok penazí.");
        	        	GivePlayerMoney(playerid, -2000);
        	        	SetPlayerArmour(playerid, 100);
						return 1;
				}
				case 2: // Desert Eagle
		        {
	                        if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid, 0xFFFFFF, "{C0C0C0}Nemáš dostatok penazí.");
        	        	GivePlayerMoney(playerid, -500);
        	        	GivePlayerWeapon(playerid, 24, 50); 
						return 1;
				}
	   			case 3: // Sawnoff Shotgun
		        {
	         		if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid, 0xFFFFFF, "{C0C0C0}Nemáš dostatok penazí.");
        	        	GivePlayerMoney(playerid, -1000);
        	        	GivePlayerWeapon(playerid, 26, 50);
			 			return 1;
				}
				case 4: // MP5
		        {
	         			if(GetPlayerMoney(playerid) < 1500) return SendClientMessage(playerid, 0xFFFFFF, "{C0C0C0}Nemáš dostatok penazí.");
        	        	GivePlayerMoney(playerid, -1500);
        	        	GivePlayerWeapon(playerid, 29, 100);
			 			return 1;
				}
				case 5: // Ak-47
		        {
	         			if(GetPlayerMoney(playerid) < 4000) return SendClientMessage(playerid, 0xFFFFFF, "{C0C0C0}Nemáš dostatok penazí.");
        	        	GivePlayerMoney(playerid, -4000);
        	        	GivePlayerWeapon(playerid, 30, 150);
			 			return 1;
				}
				case 6: // M4
		        {
	         		if(GetPlayerMoney(playerid) < 4000) return SendClientMessage(playerid, 0xFFFFFF, "{C0C0C0}Nemáš dostatok penazí.");
        	        	GivePlayerMoney(playerid, -4000);
        	        	GivePlayerWeapon(playerid, 31, 150);
			 			return 1;
				}
				case 7: // Sniper Rifle
		        {
	         		if(GetPlayerMoney(playerid) < 3500) return SendClientMessage(playerid, 0xFFFFFF, "{C0C0C0}Nemáš dostatok penazí.");
        	        	GivePlayerMoney(playerid, -3500);
        	        	GivePlayerWeapon(playerid, 34, 30);
			 			return 1;
				}
				case 8: // granade
		        {
	         		if(GetPlayerMoney(playerid) < 3000) return SendClientMessage(playerid, 0xFFFFFF, "{C0C0C0}Nemáš dostatok penazí.");
        	        	GivePlayerMoney(playerid, -3000);
        	        	GivePlayerWeapon(playerid, 16, 10);
			 			return 1;
				}

if(GetPlayerMoney a <3500 (ukážka) - zisti či má hráč danú sumu pri sebe.

 

Ked nemá napíše mu správa že nemá dostatok penazí,

 

GivePlayerMoney a -3500 mu ich odoberie (Pozor musi tam byť -).

 

GivePlayerWeapon nám sám o sebe hovori že vrah je na svete :p

 

 

 

Tento Tut som sice robil s pomocou wiki nie je to nič moc, ked som na niečo zabudol pište hned ale po jednom! 

 

 

PS: Samozrejme si músite vytvoriť aj vlastné ammu ale to nechám na vás. 

 

Link to comment
Share on other sites

jen tak byjsem ješte řekl proč používat switch kčemu to je dobre a ten tvůj "Pick up" by se furt přeskakoval takže taky nic moc 4/10 ale moc nechapu co si potřeboval vedět na wikine :d

ale ammo shop system to není je to pouze dialog se zbranema ammo shop system by jsem si představil trošku jinak 

Link to comment
Share on other sites

šílenost ... to je script ne návod

if(GetPlayerMoney a <3500 (ukážka) - zisti či má hráč danú sumu pri sebe.

 

Ked nemá napíše mu správa že nemá dostatok penazí,

 

GivePlayerMoney a -3500 mu ich odoberie (Pozor musi tam byť -).

 

GivePlayerWeapon nám sám o sebe hovori že vrah je na svete  :p

 

Taky todle neberu jako navod:D

a začínam si myslet že si tenhle mod nekde zkopčil :) "StuntPark Ammonation"

Link to comment
Share on other sites

 

if(GetPlayerMoney a <3500 (ukážka) - zisti či má hráč danú sumu pri sebe.

 

Ked nemá napíše mu správa že nemá dostatok penazí,

 

GivePlayerMoney a -3500 mu ich odoberie (Pozor musi tam byť -).

 

GivePlayerWeapon nám sám o sebe hovori že vrah je na svete  :p

 

Taky todle neberu jako navod:D

a začínam si myslet že si tenhle mod nekde zkopčil :) "StuntPark Ammonation"

 

Skopčiť som ho určite neskopčil ale keby si dával pozor by si sa dočital že som ho urobil s pomocou wiki ;) 

Link to comment
Share on other sites

  • 3 months later...

Na nováčika je to celkom v pohode...ja osobne používam switch aj na dialogid...a id dialógov robím takto:

 

 

#define Dialog_Zbrane 0

ShowPlayerDIalog(playerid, Dialog_Zbrane, ...);

switch(dialogid)
{
    case Dialog_Zbrane
    {
     // skript
   }
}

 

Je to podľa mňa jednoduchšie orientovať sa v pomenovaných dialógoch ako v číslach...hlavne ak ich máš veľa.

 

Ale nabudúce to umiestni do scriptov ;)

 

PS: Ako tu už odznelo...nie je to systém

Link to comment
Share on other sites

  • 4 months later...

Nemáte z toho niekto .pwn napísane ? keď som to skopíroval a dal do pawna tak mi to hodilo nejaké errory.

 

Tak tie errory si hod do googlu a oprav si to  :p

Link to comment
Share on other sites

  • 1 month later...

Vložil som to do OnDialogRespone a Piše mi error  error 002: only a single statement (or expression) can follow each "case"


UŽ mam problem iba z error 002: only a single statement (or expression) can follow each "case"

Link to comment
Share on other sites

if(dialogid == ID DIALOGU)
{
if(response)
{

switch(listitem)
{
case 0:
{
 //POLOŽKA 1
}
case 1:
{
 // POLOŽKA 2
}
case 2:
{
 // POLOŽKA 3
}
}
return 1;
}
}

Pokud chceš víc položek tak pokračuj v pořadí casů např. 4. položka by byla case 3 atd.

 

PS: Obnovil jsi tému starou měsíc,příště založ HELP topic...

Link to comment
Share on other sites

Tak to ale nebude tímhle "návodem" - postni pak do topicu s help code - protože tady ten code je v pohodě..
Většinou ten error píše když používáš case a hodíš do toho else

Link to comment
Share on other sites

co mam s tim zrobit                                (1525) : error 030: compound statement not closed at the end of file (started at line 1499)   je chima na 1525 riadku iba ze ja mam iba 1524 riadkov

 

 

{
    if(dialogid == 111)
    {
    if(!response) return SendClientMessage(playerid, 0xFFFFFFAA, "Odišiel si.");
    {
 
    switch(listitem)
    {
    case 0:
    {
    if(GetPlayerMoney(playerid) < 2000) return SendClientMessage(playerid, 0xFFFFFF, "{C0C0C0}Nemáš dostatok penazí.");
    GivePlayerMoney(playerid, -2000);
    SetPlayerHealth(playerid, 100);
    }
    case 1:
    {
    if(GetPlayerMoney(playerid) < 2000) return SendClientMessage(playerid, 0xFFFFFF, "{C0C0C0}Nemáš dostatok penazí.");
    GivePlayerMoney(playerid, -2000);
    SetPlayerArmour(playerid, 100);
    }
    case 2:
    {
    if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid, 0xFFFFFF, "{C0C0C0}Nemáš dostatok penazí.");
    GivePlayerMoney(playerid, -500);
    GivePlayerWeapon(playerid, 24, 50);
    }
    }
    return 1;
    }
Link to comment
Share on other sites

if(dialogid == 111)
{
if(!response) return SendClientMessage(playerid, 0xFFFFFFAA, "Odišiel si.");
{


switch(listitem)
{
case 0:
{
if(GetPlayerMoney(playerid) < 2000) return SendClientMessage(playerid, 0xFFFFFF, "{C0C0C0}Nemáš dostatok penazí.");
GivePlayerMoney(playerid, -2000);
SetPlayerHealth(playerid, 100);
}
case 1:
{
if(GetPlayerMoney(playerid) < 2000) return SendClientMessage(playerid, 0xFFFFFF, "{C0C0C0}Nemáš dostatok penazí.");
GivePlayerMoney(playerid, -2000);
SetPlayerArmour(playerid, 100);
}
case 2:
{
if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid, 0xFFFFFF, "{C0C0C0}Nemáš dostatok penazí.");
GivePlayerMoney(playerid, -500);
GivePlayerWeapon(playerid, 24, 50);
}
}
return 1;
}
}
return 0;
}

Mně to error nehází,zkus to

PS: Pokud to není poslední dialog tak tam nevkládej return 0 prosimtě...

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...