Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- Lean's Graffiti System
- **
- ****
- INCLUDES/DEFINES:
- */
- #include <a_samp>
- #include <zcmd>
- #include <streamer>
- #include <sscanf2>
- #include <foreach>
- #include <dini>
- #define LEANCMD:(%1) CMD:%1(playerid, params[])
- #define COL_WHITE "{FFFFFF}"
- #define COL_RED "{F81414}"
- #define COL_GREEN "{00FF22}"
- #define COL_LIGHTBLUE "{00CED1}"
- #define SPRAYCANSOUND "http://k003.kiwi6.com/hotlink/bfd89n1rw9/spray_sound_effect_-_odg_os_sprayu_-_bruit_spray_-_spray_noise.mp3"
- #define COLOR_LIGHTRED 0xFF6347AA
- #define SCM SendClientMessage
- #define VERSION "Graffiti V1"
- #define PRESSED(%0) \
- (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- #define RELEASED(%0) \
- (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
- #define DIALOG_WELCOME 075
- #define DIALOG_SELECT 076
- #define DIALOG_INPUTGRAFF 077
- #define DIALOG_COLOR 078
- #define DIALOG_HAPPY 079
- #define DIALOG_LIST 080
- #define COL_GREY "{C3C3C3}" // 1
- #define COL_WHITE "{FFFFFF}" // 2
- #define COL_RED "{F81414}" // 3
- #define COL_GREEN "{00FF22}" // 4
- #define COL_LIGHTBLUE "{00CED1}" // 5
- #define COL_ORANGE "{FF9900}" // 6
- #define COL_BLACK "{000000}"
- #define GRAFFDIALOG ShowPlayerDialog(playerid, DIALOG_SELECT, DIALOG_STYLE_LIST, "Graffiti Menu", "Enter Graffiti Text\nGraffiti List", "Select", "Exit");
- #define GRAFFINPUT ShowPlayerDialog(playerid, DIALOG_INPUTGRAFF, DIALOG_STYLE_INPUT, "Graffiti", "Please Enter Graffiti text", "Continue", "Cancel");
- #define GRAFFINPUTER ShowPlayerDialog(playerid, DIALOG_INPUTGRAFF, DIALOG_STYLE_INPUT, ""COL_WHITE"Graffiti", ""COL_RED"ERROR: No text was written \nPlease try again!", "Continue", "Cancel");
- #define GRAFFCOLOR ShowPlayerDialog(playerid, DIALOG_COLOR, DIALOG_STYLE_LIST, "Color Menu", "{000000}Black\n{FFFFFF}White\n{F81414}Red\n{00FF22}Green\n{00CED1}Lightblue\n{C3C3C3}Grey", "Select", "Exit");
- #define GRAFFHAPPY ShowPlayerDialog(playerid, DIALOG_HAPPY, DIALOG_STYLE_MSGBOX, "Graffiti Menu", "Please Enter Graffiti text", "Continue", "Cancel");
- #define GRAFFLIST ShowPlayerDialog(playerid,DIALOG_LIST,DIALOG_STYLE_LIST,"Graffiti List",string,"Ok","Cancel");
- #define MAXGRAFFS 50
- #define Graffitis "/Graffitis/%d.ini"
- /*-------END OF INCLUDES/DEFINES-----------*/
- /*
- NEWS;
- *
- **
- */
- new sprayammount[MAX_PLAYERS];
- new POBJECT[MAX_PLAYERS];
- new POBJECTN[MAX_PLAYERS][96];
- new POBJECTC[MAX_PLAYERS][24];
- new Float:XYZ[MAX_PLAYERS][6];
- new GRAVEH[MAX_PLAYERS];
- new spraytimer[MAX_PLAYERS];
- new spraytimerch[MAX_PLAYERS];
- new sprayammountch[MAX_PLAYERS];
- new isveh[MAX_PLAYERS] = 0;
- new sprays = 0;
- new graffmenup[MAX_PLAYERS] = 0;
- new creator[MAX_PLAYERS][MAX_PLAYER_NAME];
- new gammount;
- new spraytimerx[MAX_PLAYERS];
- /*-------END OF NEWS-----------*/
- //****ENUM****
- enum graffInfo
- {
- graffcreator[MAX_PLAYER_NAME],graffname[96],Float:Xpos,Float:Ypos,Float:Zpos,Float:XYpos,Float:YYpos,Float:ZYpos,OBJECTID
- }
- new gInfo[MAXGRAFFS][graffInfo];
- //*****STOCKS*******
- stock nGraffiti()
- {
- new ID[64]; for(new h = 0; h <= 200; h++){
- format(ID, sizeof(ID), Graffitis, h);if(!dini_Exists(ID)) return h; }return true;
- }
- stock LoadGraffitis()
- {
- new string[70];
- for(new ID = 0; ID < sizeof(gInfo); ID++)
- {
- format(string, sizeof(string), Graffitis, ID);
- if(dini_Exists(string))
- {
- strmid(gInfo[ID][graffcreator],dini_Get(string,"graffcreator"),0,MAX_PLAYER_NAME,MAX_PLAYER_NAME);
- strmid(gInfo[ID][graffname],dini_Get(string,"graffname"),0,96,96);
- gInfo[ID][OBJECTID] = dini_Int(string, "OBJECTID");
- gInfo[ID][Xpos] = dini_Float(string, "Xpos");
- gInfo[ID][Ypos] = dini_Float(string, "Ypos");
- gInfo[ID][Zpos] = dini_Float(string, "Zpos");
- gInfo[ID][XYpos] = dini_Float(string, "XYpos");
- gInfo[ID][YYpos] = dini_Float(string, "YYpos");
- gInfo[ID][ZYpos] = dini_Float(string, "ZYpos");
- }
- }
- return 1;
- }
- stock SaveGraffitis()
- {
- new string[50];
- for(new ID = 0; ID < sizeof(gInfo); ID++)
- {
- format(string, sizeof(string), Graffitis, ID);
- if(dini_Exists(string))
- {
- dini_Set(string,"graffcreator",gInfo[ID][graffcreator]);
- dini_Set(string,"graffname",gInfo[ID][graffname]);
- dini_Set(string,"OBJECTID", gInfo[ID][OBJECTID]);
- dini_FloatSet(string,"Xpos", gInfo[ID][Xpos]);
- dini_FloatSet(string,"Ypos", gInfo[ID][Ypos]);
- dini_FloatSet(string,"Zpos", gInfo[ID][Zpos]);
- dini_FloatSet(string,"XYpos", gInfo[ID][XYpos]);
- dini_FloatSet(string,"YYpos", gInfo[ID][YYpos]);
- dini_FloatSet(string,"ZYpos", gInfo[ID][ZYpos]);
- }
- }
- return 1;
- }
- stock GetName(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof(name));
- return name;
- }
- /*
- FORWARDS;
- *
- **
- */
- forward loadgraffs();
- forward spraying(playerid);
- forward sprayingch(playerid);
- forward killgr(playerid);
- forward creategraff(playerid);
- /*-------END OF FORWARDS-----------*/
- /*
- CALLBACKS;
- *
- **
- */
- public OnFilterScriptInit()
- {
- print( " Leans Graffiti System Loaded" );
- SendClientMessageToAll( -1, "Leans "VERSION" Loaded" );
- LoadGraffitis();
- loadgraffs();
- foreach(Player, i)
- {
- killgr(i);
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- SendClientMessageToAll( -1, "Leans "VERSION" UnLoaded" );
- return 1;
- }
- public loadgraffs()
- {
- for(new ID = 0; ID < MAXGRAFFS; ID++)
- {
- gInfo[ID][OBJECTID] = CreateDynamicObject( 19482, gInfo[ID][Xpos],gInfo[ID][Ypos],gInfo[ID][Zpos], gInfo[ID][XYpos], gInfo[ID][YYpos], gInfo[ID][ZYpos], -1, 0, -1, 200 ); //Creating the object
- SetDynamicObjectMaterialText( gInfo[ID][OBJECTID], 0, gInfo[ID][graffname], OBJECT_MATERIAL_SIZE_256x256, "Diploma", 25, 0, 0xFFFFFFFF, 0, 1 ); // Setting the object text with our choosen graffiti text
- gammount ++;
- }
- return 1;
- }
- public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
- {
- if( response == EDIT_RESPONSE_FINAL ) // If player press SAVE
- {
- if( GetPVarInt(playerid, "GraffitiCreating") == 1 ) //Checking if player have a positiv variable on GraffitiCreating
- {
- XYZ[playerid][0] = x; //Getting XYZ
- XYZ[playerid][1] = y;
- XYZ[playerid][2] = z;
- XYZ[playerid][3] = rx; // Getting Angles
- XYZ[playerid][4] = ry;
- XYZ[playerid][5] = rz;
- GameTextForPlayer( playerid, "Please keep spraying your spraycan till its created.",10000, 5 ); // Telling player to SPRAY with his psraycan
- DestroyDynamicObject( POBJECT[playerid] ); // When player is done with his position of the graffiti and he hits save it gets destroyed
- GivePlayerWeapon( playerid, 41, 9999 ); // DEBUGGING purposes we give him a spraycan
- spraytimerx[playerid] = SetTimerEx( "killgr", 90000, true, "i", playerid );
- }
- }
- if( response == EDIT_RESPONSE_CANCEL ) // If he hits ESC
- {
- if( GetPVarInt(playerid, "GraffitiCreating") == 1 ) //Checking if player is in creation of graffiti
- {
- DestroyDynamicObject( POBJECT[playerid] ); // Destroying the object
- SendClientMessage( playerid,0xFF6800FF,"Creation of Graffiti Canceld" ); // <---
- DeletePVar( playerid,"GraffitiCreating" ); // Deleting the PVAR from the player that he is not creating a graffiti
- }
- }
- return 1;
- }
- public creategraff( playerid )
- {
- new v = random(200+200);
- printf("%d",v);
- POBJECT[playerid] += v;
- DestroyDynamicObject( POBJECT[playerid] ); // Destroying old sprayobject
- POBJECT[playerid] = CreateDynamicObject( 19482, XYZ[playerid][0], XYZ[playerid][1], XYZ[playerid][2], XYZ[playerid][3], XYZ[playerid][4], XYZ[playerid][5], GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid), -1, 200 ); //Creating the object
- SetDynamicObjectMaterialText( POBJECT[playerid], 0, POBJECTN[playerid], OBJECT_MATERIAL_SIZE_256x256, "Diploma", 25, 0, 0xFFFFFFFF, 0, 1 ); // Setting the object text with our choosen graffiti text
- GameTextForPlayer( playerid, "~w~SPRAYED ]",5000,5 ); // SElf explainable?
- DeletePVar( playerid,"GraffitiCreating" ); // Deleting the PVAR afterwards
- sprayammount[playerid] = 0; // SEtting this var to 0, will explain what it is further down
- GRAVEH[playerid] = 0;
- isveh[playerid] = 0;
- sprays ++;
- creator[playerid] = GetName(playerid);
- new string[20];
- new id = nGraffiti();
- format(string, sizeof(string),Graffitis, id);
- dini_Create(string);
- strmid(gInfo[id][graffname] , POBJECTN[playerid], 0, strlen(POBJECTN[playerid]), 32);
- gInfo[id][graffcreator] = GetName(playerid);
- gInfo[id][OBJECTID] = POBJECT[playerid];
- gInfo[id][Xpos] = XYZ[playerid][0];
- gInfo[id][Ypos] = XYZ[playerid][1];
- gInfo[id][Zpos] = XYZ[playerid][2];
- gInfo[id][XYpos] = XYZ[playerid][3];
- gInfo[id][YYpos] = XYZ[playerid][4];
- gInfo[id][ZYpos] = XYZ[playerid][5];
- SaveGraffitis();
- StopAudioStreamForPlayer(playerid);
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if ( PRESSED(KEY_FIRE) && GetPVarInt(playerid, "GraffitiCreating") == 0 && GetPlayerWeapon(playerid) == 41 ) // CHeck if player is pressing FIRE key and if he have a positiv pvar on graffiticreating
- {
- spraytimerch[playerid] = SetTimerEx( "sprayingch", 1000, true, "i", playerid ); // STarting a timer for spraying
- SetPVarInt(playerid, "GraffitiMenu", 1);
- return 1;
- }
- if ( RELEASED( KEY_FIRE ) && GetPVarInt(playerid, "GraffitiMenu") == 1 && GetPlayerWeapon(playerid) == 41) // If player releases his fire key
- {
- KillTimer( spraytimerch[playerid] );
- GameTextForPlayer(playerid, "] ~r~Aborted",5000, 5);
- graffmenup[playerid] = 0;
- DeletePVar(playerid, "GraffitiMenu");
- return 1;
- }
- if ( PRESSED(KEY_FIRE) && GetPVarInt(playerid, "GraffitiCreating") == 1 ) // CHeck if player is pressing FIRE key and if he have a positiv pvar on graffiticreating
- {
- if( GetPlayerWeapon(playerid) == 41 ) // Checking if player is holding WEAPON SPRAYCAN
- {
- spraytimer[playerid] = SetTimerEx( "spraying", 1000, true, "i", playerid ); // STarting a timer for spraying
- PlayAudioStreamForPlayer(playerid, SPRAYCANSOUND);
- KillTimer( spraytimerx[playerid] );
- }
- }
- if ( RELEASED( KEY_FIRE ) && GetPVarInt(playerid, "GraffitiCreating") == 1 ) // If player releases his fire key
- {
- if( GetPlayerWeapon(playerid) == 41 ) // IF player has a spraycan
- {
- KillTimer( spraytimer[playerid] ); // Killing the timer so it wont keep going
- sprayammount[playerid] --; // Removing one POINT of spray for releasing the fire button
- GameTextForPlayer( playerid,"~g~Please keep spraying!!",3000, 5 ); // <---
- StopAudioStreamForPlayer(playerid);
- spraytimerx[playerid] = SetTimerEx( "killgr", 90000, true, "i", playerid );
- }
- }
- return 1;
- }
- public killgr(playerid)
- {
- sprayammount[playerid] = 0;
- DeletePVar( playerid,"GraffitiCreating" ); // Deleting the PVAR afterwards
- sprayammountch[playerid] = 0;
- graffmenup[playerid] = 0;
- return 1;
- }
- public spraying( playerid ) // This Callback gets called evrysecond
- {
- if(IsPlayerInRangeOfPoint(playerid, 3.0,XYZ[playerid][0],XYZ[playerid][1], XYZ[playerid][2]))
- {
- sprayammount[playerid] ++; //Evry second it gets called player gets ONE point
- if( sprayammount[playerid] == sprayammountch[playerid] ) // If player reached his points
- {
- KillTimer( spraytimer[playerid] ); // We kill this timer as player reached his points
- creategraff( playerid ); // We now call creategraff and the graffiti will be created
- return 1;
- }
- new string[64];
- format( string, sizeof(string),"~g~SPRAYING~n~ ~r~] ~w~%d/%d",sprayammount[playerid], sprayammountch[playerid]); // <----
- GameTextForPlayer( playerid, string, 1000,5 );
- return 1;
- }
- else
- {
- GameTextForPlayer(playerid, "] ~r~Sorry, you are too far away\n-2 points deducted ~y~]",5000, 5);
- sprayammount[playerid] -= 2;
- return 1;
- }
- }
- public sprayingch( playerid ) // This Callback gets called evrysecond
- {
- graffmenup[playerid] ++; //Evry second it gets called player gets ONE point
- if( graffmenup[playerid] == 5 ) // If player reached his points
- {
- KillTimer( spraytimerch[playerid] ); // We kill this timer as player reached his points
- GRAFFDIALOG
- return 1;
- }
- new string[64];
- format( string, sizeof(string),"~g~KEEP SPRAYING FOR GRAFFITI MENU~n~ ~r~] ~w~%d/5",graffmenup[playerid]); // <----
- GameTextForPlayer( playerid, string, 1000,5 );
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_SELECT)
- {
- if(response)
- {
- switch(listitem)
- {
- case 0: GRAFFINPUT
- case 1:
- {
- new string[ 500 ];
- // new PickupD = nGraffiti();
- //for(new ID = 0; ID < 30; ID++)
- new d[96];
- format(d, sizeof(d),"Graffiti List "COL_ORANGE"(Creator Lean)");
- new stringz[128];
- new c;
- for(new ID = 0; ID < gammount; ID++)
- {
- c = strlen(gInfo[ID][graffname]);
- format(stringz, sizeof(stringz),"/Graffitis/%d.ini",ID);
- if( c > 1 && fexist(stringz))
- {
- format(string, sizeof(string), "%s\nName: %s "COL_ORANGE"(%d) (Creator: %s)\n",string, gInfo[ID][graffname], ID,gInfo[ID][graffcreator]);
- ShowPlayerDialog(playerid,DIALOG_LIST,DIALOG_STYLE_LIST,d,string,"Delete","Cancel");
- }
- }
- }
- }
- }
- else return GameTextForPlayer(playerid, "] Graffiti Menu Aborted ]",5000, 5);
- return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
- }
- if(dialogid == DIALOG_LIST)
- {
- if(response) // If they clicked 'Select' or double-clicked a weapon
- {
- new id = listitem;
- new string[128];
- format(string, sizeof(string),"/Graffitis/%d.ini",id);
- if(!IsPlayerAdmin(playerid)) return GameTextForPlayer( playerid, "~r~You are not authorized \nto delete Graffitis!]",10000,5);
- if(!fexist(string))
- {
- format(string,sizeof(string),"~y~]~r~Something went wrong, try again~y~]",id);
- GameTextForPlayer(playerid, string,7000,3);
- return 1;
- }
- fremove(string);
- format(string,sizeof(string),"~y~]~g~Graffiti ~r~%d ~g~Succefully removed!~y~]",id);
- GameTextForPlayer(playerid, string,7000,3);
- DestroyDynamicObject( gInfo[id][OBJECTID] );
- }
- else return GRAFFDIALOG
- return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
- }
- if(dialogid == DIALOG_COLOR)
- {
- if(response) // If they clicked 'Select' or double-clicked a weapon
- {
- switch(listitem)
- {
- case 0: POBJECTC[playerid] = "000000";// BLACK
- case 1: POBJECTC[playerid] = "FFFFFF"; // WHITE
- case 2: POBJECTC[playerid] = "F81414"; // RED
- case 3: POBJECTC[playerid] = "00FF22"; // GREEN
- case 4: POBJECTC[playerid] = "00CED1"; // LIGHTBLUE
- case 5: POBJECTC[playerid] = "C3C3C3"; // GREY
- }
- new string[128];
- new string2[96];
- format(string2, sizeof(string2),"{%s} %s",POBJECTC[playerid],POBJECTN[playerid]);
- POBJECTN[playerid] = string2;
- format(string,sizeof(string), ""COL_WHITE"Are you happy with your Color? \n "COL_ORANGE"%s (Points to spray %d)1 point/second",string2, sprayammountch[playerid]);
- ShowPlayerDialog(playerid, DIALOG_HAPPY, DIALOG_STYLE_MSGBOX, "Graffiti Menu", string, "Yes!", "No :(");
- SCM(playerid, COLOR_LIGHTRED, string2);
- }
- else return GRAFFINPUT
- return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
- }
- if(dialogid == DIALOG_HAPPY)
- {
- if(response) // If they clicked 'Yes' or pressed enter
- {
- startgraff(playerid);
- }
- else // Pressed ESC or clicked cancel
- {
- GRAFFINPUT
- }
- return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
- }
- if(dialogid == DIALOG_INPUTGRAFF)
- {
- if(!response) return GRAFFDIALOG
- if(isnull(inputtext)) return GRAFFINPUTER
- else
- {
- new string[96];
- format(string, sizeof(string),"%s",inputtext);
- POBJECTN[playerid] = string;
- sprayammountch[playerid] = strlen(string); // All characters input counted
- GRAFFCOLOR
- }
- return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
- }
- return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
- }
- forward startgraff(playerid);
- public startgraff (playerid)
- {
- new Float:X[3];
- GetPlayerPos( playerid, X[0], X[1], X[2] ); // SAving players position// storing params in a format // storing text in a player callback
- POBJECT[playerid] = CreateDynamicObject( 19482, X[0], X[1], X[2], 0.0, 0.0, 0.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid), playerid, 200 ); // Creating the graffiti for player
- SetDynamicObjectMaterialText( POBJECT[playerid], 0, POBJECTN[playerid], OBJECT_MATERIAL_SIZE_256x256, "Diploma", 26, 0, 0xFFFFFFFF, 0, 1 ); // SEtting the text to what player wrote
- EditDynamicObject( playerid, POBJECT[playerid] ); // Forcing the player to move the graffiti
- SetPVarInt( playerid, "GraffitiCreating",1 ); // SEtting Graffiticreating positive for player
- return 1; // End of script.
- }
- /*-------END OF CALLBACKS-----------*/
- /*
- COMMANDS;
- *
- **
- */
- LEANCMD:(graffiti)
- {
- GRAFFDIALOG
- return 1;
- }
- /*-------END OF COMMANDS-----------*/
- /*-------END OF Leans Graffiti System Script-----------*/
Advertisement
Add Comment
Please, Sign In to add comment