Код:
#define FILTERSCRIPT
#include <a_samp>
#include <a_sampdb>
#include <zcmd>
#include <sscanf2>
#define function%0(%1) forward%0(%1);public%0(%1)
#define AFile ("Actor.db")
enum ActorInfo
{
ActorSkin,
Float: ActorX,
Float: ActorY,
Float: ActorZ,
Float: ActorA,
ActorVirtual,
ActorText[360],
ActorAd[32],
AActive,
Actor,
Text3D: ActorLabel
}
new Ainfo[MAX_ACTORS][ActorInfo];
new gValue[128];
new DB:ADB;
new Actor_AI = 1;
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" _Backup & Kralcik dinamik aktцr sistemi yьklendi!"); // This is credits do not delete !
print("--------------------------------------\n"); // ( Tьrkзeden anlamayan amipler iзin ingilizce yazdim )
if(!fexist(AFile))
{
fcreate(AFile);
printf("%s adli veritabani bulunamadi ьzьmle ben senin iзin olustururum.");
}
ADB = db_open(AFile); // dbyi aзiyoruz
LoadActor(); // db yi aзtiktan sonra Aktцrlerimizi yьklьyoruz.
return 1;
}
public OnFilterScriptExit()
{
db_close(ADB); // dbyi kapatiyoruz
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
return 1;
}
public OnPlayerConnect(playerid)
{
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}
CMD:createactor(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE60000FF, "ERROR | {FFFFFF}Only RCON admins can use this command.");
if(GetLastID() > MAX_ACTORS) return SendClientMessage(playerid, 0xE60000FF, "ERROR | {FFFFFF}Max Actor!");
new Float:PPos[4], string[128], query[256],SkinID,ActorNamee[32],Text[250];
GetPlayerPos(playerid, PPos[0], PPos[1], PPos[2]);
GetPlayerFacingAngle(playerid,PPos[3]);
if(sscanf(params,"ssi",ActorNamee,Text,SkinID)) return SendClientMessage(playerid, 0xE60000FF, "Usage: /createactor [Name] [Text] [Skin ID]");
format(query, sizeof(query), "INSERT INTO `ActorDB` (`ActorX`,`ActorY`,`ActorZ`, `ActorName`,`Text`, `ActorVirtual`, `ActorA`,`Skin`,`AActive`) VALUES('%f','%f','%f','%s','%s','%i','%f','%i','1');",PPos[0], PPos[1], PPos[2],ActorNamee,Text,GetPlayerVirtualWorld(playerid),PPos[3],SkinID);
db_query(ADB,query);
format(string,sizeof(string),"{0F96C7}Actor ID:{FFFFFF} %d\n{0F96C7}Actor Name:{FFFFFF} %s\nActor Text:{FFFFFF} %s\nActor Skin:{FFFFFF} %i",Actor_AI, ActorNamee,Text,SkinID);
ShowPlayerDialog(playerid,999,DIALOG_STYLE_MSGBOX,"{0F96C7}Dynamic Actor System {FFFFFF}| Actor Created",string,"Close","");
SetPlayerPos(playerid, PPos[0] + (1.5 * floatsin(-PPos[3], degrees)), PPos[1] + (1.5 * floatcos(-PPos[3], degrees)), PPos[2]);
K_B_CreateActor(ActorNamee,Actor_AI,Text,SkinID,PPos[0],PPos[1],PPos[2],PPos[3],GetPlayerVirtualWorld(playerid),1);
Actor_AI ++;
return 1;
}
CMD:removeactor(playerid,params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE60000FF, "ERROR | {FFFFFF}Only RCON admins can use this command.");
new ID;
if(sscanf(params,"i",ID)) return SendClientMessage(playerid,0xE60000FF,"Usage: /removeactor [Actor ID]");
new query[250];
Ainfo[ID][AActive] = 0;
format(query, sizeof(query), "UPDATE `ActorDB` SET `AActive` = '0' WHERE `ActorName` = '%s'",Ainfo[ID][ActorAd]);
db_query(ADB,query);
DestroyActor(Ainfo[ID][Actor]);
Delete3DTextLabel(Ainfo[ID][ActorLabel]);
SendClientMessage(playerid,-1,"Actor Deleted.");
return true;
}
CMD:editactor(playerid,params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE60000FF, "ERROR | {FFFFFF}Only RCON admins can use this command.");
new akid ,Text[256],SkinID,Float:PPos[4],ActorNamee[32],query[500];
if(sscanf(params,"is[32]s[250]i,",akid,ActorNamee,Text,SkinID)) return SendClientMessage(playerid,0xE60000FF,"Usage : /editactor [ActorID] [New Name] [New Text] [Skin OD]");
if(Ainfo[akid][AActive] == 0) return SendClientMessage(playerid, 0xE60000FF ,"ERROR | {FFFFFF}This actor is not active.");
GetPlayerPos(playerid, PPos[0], PPos[1], PPos[2]);
GetPlayerFacingAngle(playerid,PPos[3]);
DestroyActor(Ainfo[akid][Actor]);
Delete3DTextLabel(Ainfo[akid][ActorLabel]);
new ad[32];
//ad = Name
format(ad,32,"%s",Ainfo[akid][ActorAd]);
format(query, sizeof(query), "UPDATE `ActorDB` SET `ActorName` = '%s' WHERE `ActorName` = '%s'",ActorNamee,ad);
db_query(ADB,query);
format(query, sizeof(query), "UPDATE `ActorDB` SET `ActorX` = '%f' WHERE `ActorName` = '%s'",PPos[0],ad);
db_query(ADB,query);
format(query, sizeof(query), "UPDATE `ActorDB` SET `ActorY` = '%f' WHERE `ActorName` = '%s'",PPos[1],ad);
db_query(ADB,query);
format(query, sizeof(query), "UPDATE `ActorDB` SET `ActorZ` = '%f' WHERE `ActorName` = '%s'",PPos[2],ad);
db_query(ADB,query);
format(query, sizeof(query), "UPDATE `ActorDB` SET `ActorA` = '%f' WHERE `ActorName` = '%s'",PPos[3],ad);
db_query(ADB,query);
format(query, sizeof(query), "UPDATE `ActorDB` SET `Skin` = '%i' WHERE `ActorName` = '%s'",SkinID,ad);
db_query(ADB,query);
format(query, sizeof(query), "UPDATE `ActorDB` SET `Text` = '%s' WHERE `ActorName` = '%s'",Text,ad);
db_query(ADB,query);
format(query, sizeof(query), "UPDATE `ActorDB` SET `ActorVirtual` = '%i' WHERE `ActorName` = '%s'",GetPlayerVirtualWorld(playerid),ad);
db_query(ADB,query);
SetPlayerPos(playerid, PPos[0] + (1.5 * floatsin(-PPos[3], degrees)), PPos[1] + (1.5 * floatcos(-PPos[3], degrees)), PPos[2]);
K_B_CreateActor(ActorNamee,akid,Text,SkinID,PPos[0],PPos[1],PPos[2],PPos[3],GetPlayerVirtualWorld(playerid),1);
return true;
}
/// Stocklar
stock GetLastID()
{
new DBResult:qresult, count = 0, Value[128];
qresult = db_query(ADB, "SELECT * FROM `ActorDB` ORDER BY `ID` DESC LIMIT 1");
count = db_num_rows(qresult);
for(new a=0;a<count;a++)
{
if(count <= MAX_ACTORS)
{
db_get_field_assoc(qresult, "ID", Value, 5); gValue[a] = Value[a]+1;
db_next_row(qresult);
}
}
db_free_result(qresult);
return 1;
}
stock fcreate(filename[])
{
if (fexist(filename)){return false;}
new File:fhandle = fopen(filename,io_write);
fclose(fhandle);
return true;
}
stock LoadActor()
{
new query[356], DBResult:qresult, count = 0, value[128],string[356],Float:xim,Float:yim,Float:zim,Float:aim,gelenText[356],ActorName[32],
Actorvirtualim,ActorSkin2,adurum3;
if(!db_query(DB: ADB, "SELECT * FROM `ActorDB`"))
{
print("Actor tablosu bulunamadi! Ben senin icin olusturuyorum...");
format(query,sizeof(query),"CREATE TABLE IF NOT EXISTS `ActorDB` (`ID` INTEGER PRIMARY KEY AUTOINCREMENT,`ActorName` TEXT,`ActorVirtual`INTEGER ,`ActorX` TEXT,`ActorA` TEXT,`ActorY` TEXT,`ActorZ` TEXT,`Skin` INTEGER ,`AActive` INTEGER ,`Text` TEXT)");
db_query(ADB,query);
print("--------------------------------------\n");
print("Aktцr tablosu olusturuldu sunucuya restart atman gerekiyor...");
print("--------------------------------------\n");
SendRconCommand("exit");
}
else
{
qresult = db_query(ADB, "SELECT * FROM `ActorDB`");
count = db_num_rows(qresult);
for(new a=0;a<count;a++)
{
if(count >= 1 && count <= MAX_ACTORS)
{
db_get_field_assoc(qresult, "ActorX", value, 20); xim = floatstr(value);
db_get_field_assoc(qresult, "ActorY", value, 20); yim = floatstr(value);
db_get_field_assoc(qresult, "ActorZ", value, 20); zim = floatstr(value);
db_get_field_assoc(qresult, "ActorA", value, 20); aim = floatstr(value);
db_get_field_assoc(qresult, "Text",string,356); format(gelenText,356,string);
db_get_field_assoc(qresult, "ActorName",string,35); format(ActorName,32,string);
db_get_field_assoc(qresult, "ActorVirtual", value, 20); Actorvirtualim = strval(value);
db_get_field_assoc(qresult, "Skin", value, 20); ActorSkin2 = strval(value);
db_get_field_assoc(qresult, "AActive", value, 20); adurum3 = strval(value);
if(adurum3 == 1)
{
K_B_CreateActor(ActorName,Actor_AI,gelenText,ActorSkin2,xim,yim,zim,aim,Actorvirtualim,adurum3);
Actor_AI++;
}
db_next_row(qresult);
}
}
db_free_result(qresult);
print("Backup & Kralcik aktцr sistemi suanda yьklendi.");
print("--------------------------------------\n");
}
return true;
}
stock K_B_CreateActor(ActorNeym[],ActorID,BilgiText[],Smodel,Float:Axxx,Float:Ayyy,Float:Azzz,Float:Aaaa,AWorld,adurum)
{
if(adurum == 1)
{
new dongustr[256];
format(dongustr,256,"%s(%i)\n%s",ActorNeym,ActorID,BilgiText);
Ainfo[ActorID][ActorLabel] = Create3DTextLabel(dongustr, 0x008080FF, Axxx, Ayyy, Azzz, 20.0, AWorld, 0);
Ainfo[ActorID][Actor] = CreateActor(Smodel,Axxx,Ayyy,Azzz,Aaaa);
SetActorVirtualWorld(Ainfo[ActorID][Actor], AWorld);
Ainfo[ActorID][AActive] = 1;
Ainfo[ActorID][ActorX] = Axxx;
Ainfo[ActorID][ActorY] = Ayyy;
Ainfo[ActorID][ActorZ] = Azzz;
Ainfo[ActorID][ActorA] = Aaaa;
Ainfo[ActorID][ActorVirtual] = AWorld;
Ainfo[ActorID][ActorSkin] = Smodel;
format(Ainfo[ActorID][ActorAd],32,ActorNeym);
format(Ainfo[ActorID][ActorText],256,BilgiText);
}
return true;
}