Problem(error/warning): Nece da mi lepo cuva aktora nece ni da ga kreira kako treba
Dio skripte: [pawn]//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
#define AKTOR_FILE "Aktori/%d.ini"
#define MAX_AKTORI 300
enum AKTOR_INFO {
Float:ActorPos[6],
aktorskin,
aktorime[ 40 ],
aktoranimacija,
aktorid,
}
new AktorInfo[ MAX_AKTORI ][ AKTOR_INFO ], Text3D:AktorLabel[ sizeof(AktorInfo) ];
//------------------------------------------------------------------------------
sacuvajactora(id)
{
new query[1048];
format(query, sizeof(query), "Actor_Ime='%s',Actor_X='%f',Actor_Y='%f',Actor_Z='%f',Actor_A='%i',Actor_Skin='%i',Actor_Animacija='%i'",
AktorInfo[ id ][ aktorid ],
AktorInfo[ id ][ aktorime ],
AktorInfo[ id ][ ActorPos ][ 0 ],
AktorInfo[ id ][ ActorPos ][ 1 ],
AktorInfo[ id ][ ActorPos ][ 2 ],
AktorInfo[ id ][ ActorPos ][ 3 ],
AktorInfo[ id ][ aktorskin ],
AktorInfo[ id ][ aktoranimacija ]);
format(query, sizeof(query), "UPDATE aktori SET %s WHERE Actor_Id='%i'", query, AktorInfo[ id ][ aktorid ]);
mysql_function_query(Zylantmajskvel, query, false, "", "");
return 1;
}
//------------------------------------------------------------------------------
GetAktorID()
{
for(new i=0; i<sizeof(AktorInfo); i++)
{
if(AktorInfo[aktorid]==0)return i;
}
return 0;
}
//------------------------------------------------------------------------------
forward AktoraNapravi(id);
public AktoraNapravi(id)
{
AktorInfo[ id ][ aktorid ] = cache_insert_id();
}
forward UcitajAktore();
public UcitajAktore()
{
new num_aktorim,num_aktorima;
cache_get_data(num_aktorima,num_aktorim,Zylantmajskvel);
if(!num_aktorima)return 1;
for(new i=0; i<num_aktorima; i++)
{
new id = GetAktorID();
cache_get_field_content( i, "Actor_Ime", AktorInfo[ id ][ aktorime ], Zylantmajskvel, 45 );
AktorInfo[ id ][ ActorPos ][ 0 ] = cache_get_field_content_float(i, "Actor_X", Zylantmajskvel);
AktorInfo[ id ][ ActorPos ][ 1 ] = cache_get_field_content_float(i, "Actor_Y", Zylantmajskvel);
AktorInfo[ id ][ ActorPos ][ 2 ] = cache_get_field_content_float(i, "Actor_Z", Zylantmajskvel);
AktorInfo[ id ][ ActorPos ][ 3 ] = cache_get_field_content_float(i, "Actor_A", Zylantmajskvel);
AktorInfo[ id ][ aktorid ] = cache_get_field_content_int(i, "Actor_Id", Zylantmajskvel);
AktorInfo[ id ][ aktorskin ] = cache_get_field_content_int(i, "Actor_Skin", Zylantmajskvel);
AktorInfo[ id ][ aktoranimacija ] = cache_get_field_content_int(i, "Actor_Animacija", Zylantmajskvel);
KreirajAktora( id );
AktorLabelPickup( id );
}
return 1;
}
//------------------------------------------------------------------------------
stock KreirajAktora(actorem)
{
new str[128], aktornick[ 40 ];
SetPlayerPos(actorem, AktorInfo[ actorem ][ ActorPos ][ 0 ]+2, AktorInfo[ actorem ][ ActorPos ][ 1 ]+2, AktorInfo[ actorem ][ ActorPos ][ 2 ]);
AktorInfo[ actorem ][ aktorid ] = CreateActor(AktorInfo[ actorem ][ aktorskin ], AktorInfo[ actorem ][ ActorPos ][ 0 ], AktorInfo[ actorem ][ ActorPos ][ 2 ], AktorInfo[ actorem ][ ActorPos ][ 2 ], AktorInfo[ actorem ][ ActorPos ][ 3 ]);
ApplyActorAnimation(AktorInfo[ actorem ][ aktorid ], "DEALER","DEALER_IDLE", 4.0,1, 1, 1, 1, 0);
format(str, sizeof(str), ""SRWBOJA"%s\n"C_BELA"(( ID: %d ))", aktornick, actorem);
AktorLabel[ actorem ] = Create3DTextLabel(str, -1, AktorInfo[ actorem ][ ActorPos ][ 0 ], AktorInfo[ actorem ][ ActorPos ][ 2 ], AktorInfo[ actorem ][ ActorPos ][ 2 ]+1.0, 10.0, 0);
sacuvajactora(actorem);
return 1;
}
//------------------------------------------------------------------------------
stock AktorLabelPickup( actorem )
{
new str[128], aktornick[ 40 ];
SetPlayerPos(actorem, AktorInfo[ actorem ][ ActorPos ][ 0 ]+2, AktorInfo[ actorem ][ ActorPos ][ 1 ]+2, AktorInfo[ actorem ][ ActorPos ][ 2 ]);
AktorInfo[ actorem ][ aktorid ] = CreateActor(AktorInfo[ actorem ][ aktorskin ], AktorInfo[ actorem ][ ActorPos ][ 0 ], AktorInfo[ actorem ][ ActorPos ][ 2 ], AktorInfo[ actorem ][ ActorPos ][ 2 ], AktorInfo[ actorem ][ ActorPos ][ 3 ]);
ApplyActorAnimation(AktorInfo[ actorem ][ aktorid ], "DEALER","DEALER_IDLE", 4.0,1, 1, 1, 1, 0);
format(str, sizeof(str), ""SRWBOJA"%s\n"C_BELA"(( ID: %d ))", aktornick, actorem);
AktorLabel[ actorem ] = Create3DTextLabel(str, -1, AktorInfo[ actorem ][ ActorPos ][ 0 ], AktorInfo[ actorem ][ ActorPos ][ 2 ], AktorInfo[ actorem ][ ActorPos ][ 2 ]+1.0, 10.0, 0);
return 1;
}
//------------------------------------------------------------------------------[/pawn]
Dialog ,tjst komanda
[pawn]fDialog(16512)
{
new skinid;
if(sscanf(inputtext, "d", skinid)) return SPD(playerid, 16512, DIALOG_STYLE_INPUT, ""C_BELA"Kreiranje aktora", ""C_BELA"Unesite ID skina aktora.\nPrimer: "C_BELA"294", "U redu", "Izlaz");
if(skinid > 311) return SPD(playerid, 16512, DIALOG_STYLE_INPUT, ""SRWBOJA"Kreiranje aktora", ""C_BELA"*Pogresili ste id aktora, minimalan je 0 a maksimalan 311\n"C_BELA"Unesite ID skina aktora.\nPrimer: "C_BELA"294", "U redu", "Izlaz");
new aktoric = GetAktorID();
AktorInfo[ aktoric ][ aktorskin ] = skinid;
AktorInfo[aktoric][aktorskin];
new Float:PozX, Float:PozY, Float:PozZ;
//GetPlayerPos( playerid, PozX, PozY, PozZ );
AktorInfo[ aktoric ][ ActorPos ][ 0 ] = PozX;
AktorInfo[ aktoric ][ ActorPos ][ 1 ] = PozY;
AktorInfo[ aktoric ][ ActorPos ][ 2 ] = PozZ;
ShowPlayerDialog(playerid, 16513, DIALOG_STYLE_INPUT, ""C_BELA"Kreiranje aktora", ""C_BELA"Unesite ime aktora\nPrimer: "C_BELA"(( MAFIA BOSS ))", "U redu", "Izlaz");
return 1;
}
fDialog(16513)
{
new aktornick[ 40 ];
new aktoric = GetAktorID();
if(sscanf(inputtext, "s[40]", aktornick)) return ShowPlayerDialog(playerid, 16513, DIALOG_STYLE_INPUT, ""C_BELA"Kreiranje aktora", ""C_BELA"Unesite ime aktora\nPrimer: "C_BELA"(( MAFIA BOSS ))", "U redu", "Izlaz");
AktorInfo[ aktoric ][ aktorime ] = aktornick;
//GetPlayerPos( playerid, PozX, PozY, PozZ );
new queryaktors[256];
format(queryaktors, sizeof(queryaktors),
"INSERT INTO aktori ( Actor_Ime,Actor_X,Actor_Y,Actor_Z,Actor_A,Actor_Skin,Actor_Animacija) VALUES ('%i', '%s', '%f', '%f', '%f', '%f', '%f')",
AktorInfo[aktoric][aktorime],
AktorInfo[aktoric][ ActorPos ][ 0 ],
AktorInfo[aktoric][ ActorPos ][ 1 ],
AktorInfo[aktoric][ ActorPos ][ 2 ],
AktorInfo[aktoric][aktorskin],
AktorInfo[aktoric][aktoranimacija]);
mysql_function_query(Zylantmajskvel, queryaktors, true, "AktoraNapravi", "i", aktoric);
KreirajAktora(aktoric);
sacuvajactora( aktoric );
SendMessage( playerid, "Zavrsio si sa kreiranjem aktora." );
return 1;
}[/pawn]
Debug iz server_log(ukoliko je u pitanju crashanje servera - crashdetect log): [ code ]nema[ /code ]
Slika/video ingame problema(obavezno ako je ingame problem): https://imgur.com/a/snBHCCj
Actor_A=`%i` ====> Actor_A=`%f`
Prije svega podji da koristis mysql_format zbog %e tj. Escape stringa i sigurnosti protiv mysql injectiona. Takodjer i mysql_tquery umjesto function querya-a. Naravno moras pazit sa threadovima ukoliko nisi imao ranije iskustva jer se moze lako abuse-at i zbugat. GL. ;)
Citat: TarikBrt poslato Mart 23, 2020, 18:20:16 POSLE PODNE
Prije svega podji da koristis mysql_format zbog %e tj. Escape stringa i sigurnosti protiv mysql injectiona. Takodjer i mysql_tquery umjesto function querya-a. Naravno moras pazit sa threadovima ukoliko nisi imao ranije iskustva jer se moze lako abuse-at i zbugat. GL. ;)
znm za sve to ali razmisljam da predjem na mysql r41 posto je mnogo laksi od ovog a mrzi me da prebacujem jer stvarno mnogo ima
Citat: .agency poslato Mart 23, 2020, 17:21:05 POSLE PODNE
Actor_A=`%i` ====> Actor_A=`%f`
ma dzabe opet isto nece me spawna actora nigde
Fix Sam moze lock