Jump to content
  • 0

pomoc Bojové styly


1Kubad1

Dotaz

caute upravil jsem bojove styly z netu ale mam problem kdyz dam /carmenu tak se to buguje tak se ptam kde je neco z dialogu

 

#include <a_samp>
#include <zcmd>
#include <YSI\y_ini>

#define COLOR_LRED 0xFF1111FF

new PlayerFile[13 + MAX_PLAYER_NAME + 1];

forward LoadStyles(playerid, name[], value[]);


public OnPlayerDisconnect(playerid, reason)
{
if(INI_Exist(pName(playerid)))
{
format(PlayerFile , sizeof PlayerFile, "FightingStyles/%s.ini", Encode(pName(playerid)));
new INI:PlayerFS = INI_Open(PlayerFile);
INI_WriteInt(PlayerFS, "FightingStyles", GetPVarInt(playerid, "FightingStyle"));
INI_Close(PlayerFS);
}
return 1;
}
public OnPlayerSpawn(playerid)
{
LoadFightStyle(playerid);
return 1;
}

public OnPlayerConnect(playerid)
{
format(PlayerFile , sizeof PlayerFile, "FightingStyles/%s.ini", Encode(pName(playerid)));
if(!INI_Exist(pName(playerid)))
{
new INI:PlayerFS = INI_Open(PlayerFile);
INI_WriteInt(PlayerFS, "FightingStyles", 0);
INI_Close(PlayerFS);
}
else if(INI_Exist(pName(playerid)))
{
INI_ParseFile(PlayerFile, "LoadStyles", false, true, playerid, true, false);
}
return 1;
}

CMD:kungfu(playerid, params[])
{
ShowPlayerDialog(playerid, 154, DIALOG_STYLE_MSGBOX, "Kungfu", "Naucil si se Kungfu za 6000 $", "ok", "ok");
GivePlayerMoney(playerid, -6000);
SetPlayerFightingStyle (playerid, FIGHT_STYLE_KUNGFU);
SetPVarInt(playerid, "FightingStyle", 5);
return 1;
}

CMD:elbow(playerid, params[])
{
ShowPlayerDialog(playerid, 157, DIALOG_STYLE_MSGBOX, "Elbow", "Naucil si se Elbow za 2000 $", "ok", "ok");
GivePlayerMoney(playerid, -2000);
SetPlayerFightingStyle (playerid, FIGHT_STYLE_ELBOW);
SetPVarInt(playerid, "FightingStyle", 1);
return 1;
}
CMD:boxing(playerid, params[])
{
ShowPlayerDialog(playerid, 158, DIALOG_STYLE_MSGBOX, "Boxing", "Naucil si se Boxing za 5000 $", "ok", "ok");
GivePlayerMoney(playerid, -5000);
SetPlayerFightingStyle (playerid, FIGHT_STYLE_BOXING);
SetPVarInt(playerid, "FightingStyle", 2);
return 1;
}
CMD:grabkick(playerid, params[])
{
ShowPlayerDialog(playerid, 159, DIALOG_STYLE_MSGBOX, "Grabkick", "Naucil si se Grabkick za 1000 $", "ok", "ok");
GivePlayerMoney(playerid, -1000);
SetPlayerFightingStyle (playerid, FIGHT_STYLE_GRABKICK);
SetPVarInt(playerid, "FightingStyle", 3);
return 1;
}
CMD:normal(playerid, params[])
{
ShowPlayerDialog(playerid, 155, DIALOG_STYLE_MSGBOX, "Normal", "mas zpatky defaltni styl boje", "ok", "ok");
SetPlayerFightingStyle (playerid, FIGHT_STYLE_NORMAL);
SetPVarInt(playerid, "FightingStyle", 0);
return 1;
}
CMD:kneehead(playerid, params[])
{
ShowPlayerDialog(playerid, 160, DIALOG_STYLE_MSGBOX, "Kneehead", "Naucil si se Kneedhead za 4000 $", "ok", "ok");
GivePlayerMoney(playerid, -4000);
SetPlayerFightingStyle (playerid, FIGHT_STYLE_KNEEHEAD);
SetPVarInt(playerid, "FightingStyle", 4);
return 1;
}

public LoadStyles(playerid, name[ ], value[ ])
{
if(!strcmp(name, "FightingStyles")) SetPVarInt(playerid, "FightingStyle", strval(value));
}
stock LoadFightStyle(playerid)
{
 if(GetPVarInt(playerid, "FightingStyle") == 1)
 {
		 SetPlayerFightingStyle(playerid, FIGHT_STYLE_ELBOW);
 }
 else if(GetPVarInt(playerid, "FightingStyle") == 2)
 {
		 SetPlayerFightingStyle(playerid, FIGHT_STYLE_BOXING);
 }
 else if(GetPVarInt(playerid, "FightingStyle") == 3)
 {
		 SetPlayerFightingStyle(playerid, FIGHT_STYLE_GRABKICK);
 }
 else if(GetPVarInt(playerid, "FightingStyle") == 4)
 {
		 SetPlayerFightingStyle(playerid, FIGHT_STYLE_KNEEHEAD);
 }
 else if(GetPVarInt(playerid, "FightingStyle") == 5)
 {
		 SetPlayerFightingStyle(playerid, FIGHT_STYLE_KUNGFU);
 }
 else if(GetPVarInt(playerid, "FightingStyle") == 0)
 {
		 SetPlayerFightingStyle(playerid, FIGHT_STYLE_NORMAL);
 }
 return 1;
}

stock pName(playerid)
{
new namep[MAX_PLAYER_NAME];
GetPlayerName(playerid,namep,sizeof(namep));
return namep;
}
stock INI_Exist(nickname[])
{
new tmp[255];
format(tmp,sizeof(tmp),"FightingStyles/%s.ini",Encode(nickname));
return fexist(tmp);
}

stock Encode(nickname[])
{
new tmp[255];
set(tmp,nickname);
tmp=strreplace("_","_00",tmp);
tmp=strreplace(";","_01",tmp);
tmp=strreplace("!","_02",tmp);
tmp=strreplace("/","_03",tmp);
tmp=strreplace("\\","_04",tmp);
tmp=strreplace("[","_05",tmp);
tmp=strreplace("]","_06",tmp);
tmp=strreplace("?","_07",tmp);
tmp=strreplace(".","_08",tmp);
tmp=strreplace("*","_09",tmp);
tmp=strreplace("<","_10",tmp);
tmp=strreplace(">","_11",tmp);
tmp=strreplace("{","_12",tmp);
tmp=strreplace("}","_13",tmp);
tmp=strreplace(" ","_14",tmp);
tmp=strreplace("\"","_15",tmp);
tmp=strreplace(":","_16",tmp);
tmp=strreplace("|","_17",tmp);
tmp=strreplace("=","_18",tmp);
return tmp;
}

stock set(dest[],source[])
{
 new
	 count = strlen(source),
	 i=0
 ;
 for(i=0;i<count;i++) dest[i]=source[i];
 dest[count]=0;
}

stock strreplace(trg[],newstr[],src[])
{
new
	 f=0,
	 s1[255],
	 tmp[255]
 ;
format(s1,sizeof(s1),"%s",src);
f = strfind(s1,trg);
tmp[0]=0;
while (f>=0)
 {
 strcat(tmp,ret_memcpy(s1, 0, f));
 strcat(tmp,newstr);
 format(s1,sizeof(s1),"%s",ret_memcpy(s1, f+strlen(trg), strlen(s1)-f));
 f = strfind(s1,trg);
 }
strcat(tmp,s1);
return tmp;
}

ret_memcpy(source[],index=0,numbytes)
{
 new
	 tmp[255],
	 i=0
 ;
 tmp[0]=0;
 if(index>=strlen(source)) return tmp;
 if(numbytes+index>=strlen(source)) numbytes=strlen(source)-index;
 if(numbytes<=0) return tmp;
 for(i=index;i<numbytes+index;i++)
 {
	 tmp[i-index]=source[i];
	 if(source[i]==0) return tmp;
 }
 tmp[numbytes]=0;
 return tmp;
}

Link to comment
Share on other sites

11 odpovědí na tuto otázku

Recommended Posts

  • 0

já ho chápu -_- prostě misto Bojoveho stylu se mu spawne Auto, to je bug který se stáva často když je na serveru hodně Dialogu

To mas asi jasno vedecke schopnosti pokud si to vycetl z tohoto:

caute upravil jsem bojove styly z netu ale mam problem kdyz dam /carmenu tak se to buguje tak se ptam kde je neco z dialogu

:d

  • Líbí se mi to! (+1) 1
Link to comment
Share on other sites

  • 0

Vsak to má přez Dialog =D a Carmenu je taky přez Dialog =D

A co jako ? Vyraz BUG je dost siroky, k reseni problemu potrebujes presnou definici problemu. To je asi taky ten duvod proc neni schopen ten problem opravit sam. Protoze neni ani schopny pochopit co se vlastne stalo, a misto toho to nazve BUGem.

Link to comment
Share on other sites

  • 0

Je to spôsobené že nie všetky FS majú return 0; v OnDialogResponse (na konci publicu) ale niektoré majú return 1; čo zastaví beh scriptu pre iné FS & GM

Jedna z moznosti, vice bychom vedeli kdyby se vyjadril poradne.

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...