Noticias:

No tienes permiso para ver los enlaces. Para poder verlos Registrate o Conectate.

Menú Principal

Sistema de Grafitis

Iniciado por Swarlog, May 13, 2025, 06:45 PM

Tema anterior - Siguiente tema

Swarlog

No puedes ver este adjunto.

Información Adicional:

Ideal para RP, unicamente las bandas puedes hacer pintadas. Espero que os guste!

Código:

#include <a_samp>

// #define VERDE 0x00FF00FF // No se lo utiliza pero por si la necesitan se los dejo
#define ROJO 0xFD0000FF
#define BLANCO 0xFFFFFFFF

#define GRAFFITI_MAXIMOS    500
#define GRAFFITI_BALLA  	1525
#define GRAFFITI_GROVE   	1528
#define GRAFFITI_VAGO   	1530
#define GRAFFITI_CORONA   	1526
enum tagInfo
{
	tgSprayer[24],
	Float:tgX,
	Float:tgY,
	Float:tgZ,
};

new Spray[GRAFFITI_MAXIMOS],Tag,pintados[MAX_PLAYERS];
new TagInfo[GRAFFITI_MAXIMOS][tagInfo];

forward pintando(playerid);

public OnFilterScriptInit()
{
	Tag = 0;
	return 1;
}

public OnPlayerConnect(playerid)
{
	pintados[playerid] = 0;
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{

	if(strcmp(cmdtext, "/borrargraffitis", true)==0)
	{
	    if (Tag == 0) return SendClientMessage(playerid,ROJO,"No se a encontrado Graffitis a los alrededores");
	    if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,ROJO,"No eres un administrador");
    	for(new stags = 1; stags <= 200; stags++)
    	{
    	    DestroyObject(Spray[stags]);
    	    Tag = 0;
    	}
    	return 1;
	}
	if(strcmp(cmdtext, "/borrargraffiti", true)==0)
    {
        new total;
        new frm[128];
        for(new i = 0; i < GRAFFITI_MAXIMOS; i++)
	    {
	        if(PlayerToPoint(playerid,2,TagInfo[i][tgX],TagInfo[i][tgY],TagInfo[i][tgZ]))
	        {
	            GetPlayerName(playerid, frm, MAX_PLAYER_NAME);
    			if (!strcmp(TagInfo[i][tgSprayer],frm))
    			{
					DestroyObject(Spray[i]);
					TagInfo[i][tgX] = 0;
			        TagInfo[i][tgY] = 0;
			        TagInfo[i][tgZ] = 0;
			        Spray[i] = INVALID_OBJECT_ID;
			        strmid(TagInfo[i][tgSprayer], " ", 0, 1);
			        Tag--;
			        total++;
				}
			}
		}
		format(frm, sizeof(frm), " Has borrado %d graffitis", total);
		SendClientMessage(playerid, BLANCO, frm);
    	return 1;
    }
    if(strcmp(cmdtext, "/borrartag", true)==0)
    {
        if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, ROJO, " No eres un administrador");
        new total;
        new frm[128];
        for(new i = 0; i < GRAFFITI_MAXIMOS; i++)
	    {
	        if(PlayerToPoint(playerid,2,TagInfo[i][tgX],TagInfo[i][tgY],TagInfo[i][tgZ]))
	        {
				DestroyObject(Spray[i]);
				TagInfo[i][tgX] = 0;
    			TagInfo[i][tgY] = 0;
			    TagInfo[i][tgZ] = 0;
				Spray[i] = INVALID_OBJECT_ID;
       			strmid(TagInfo[i][tgSprayer], " ", 0, 1);
		        Tag--;
		        total++;
			}
		}
		format(frm, sizeof(frm), " Has borrado %d Graffitis", total);
		SendClientMessage(playerid, BLANCO, frm);
    	return 1;
    }
	if(strcmp(cmdtext, "/pintar", true)==0)
	{
	    if (Tag == 0) return SendClientMessage(playerid,ROJO,"No puedes pintar un graffiti");
	    new string[128];
	    for(new stags = 0; stags < GRAFFITI_MAXIMOS; stags++)
    	{
    		if (PlayerToPoint(playerid,2,TagInfo[stags][tgX],TagInfo[stags][tgY],TagInfo[stags][tgZ]))
      		{
				printf("%d - %d",Tag,stags);
    		   	format(string,sizeof(string),"Graffitis: %s - Tag #%d",TagInfo[stags][tgSprayer],stags);
    		   	SendClientMessage(playerid,BLANCO,string);
      		}
		}
    	return 1;
	}
	return 0;
}

public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
	if (newkeys == KEY_FIRE && GetPlayerWeapon(playerid) == 41)
	{
		SetTimerEx("pintando",2000,0,"d",playerid);
	}
	return 1;
}

public pintando(playerid)
{
	new keys,updown,leftright;
	GetPlayerKeys(playerid,keys,updown,leftright);
	if (keys == KEY_FIRE)
	{
	    if (GetPlayerSkin(playerid) >= 102 && GetPlayerSkin(playerid) <= 104) // Ballas
	    {
	        for(new stags = Tag; stags < GRAFFITI_MAXIMOS; stags++)
	        {
	       		if (Tag >= GRAFFITI_MAXIMOS-1) return SendClientMessage(playerid,ROJO,"Ya hay demasiados Graffitis pintados.");
	    		new Float:X, Float:Y, Float:Z,Float:A,name[24];
				GetPlayerPos(playerid, X, Y, Z);
				GetPlayerFacingAngle(playerid, A);
				GetPlayerName(playerid,name,24);
				X += (1 * floatsin(-A, degrees));
				Y += (1 * floatcos(-A, degrees));
				TagInfo[stags][tgX] = X;
    			TagInfo[stags][tgY] = Y;
    			TagInfo[stags][tgZ] = Z;
				pintados[playerid] = 1;
				Tag += 1;
    			Spray[stags] = CreateObject(GRAFFITI_BALLA, X, Y, Z, 0.0, 0.0, A+90);
    			GameTextForPlayer(playerid,"~r~~h~Grafiti pintado",3000,3);
    			PlayerPlaySound(playerid,1057,0,0,0);
    			strmid(TagInfo[stags][tgSprayer], name, 0, strlen(name),128);
    			printf("[TAG] %s - %d",TagInfo[stags][tgSprayer],stags);
    			break;
			}
		}
		if (GetPlayerSkin(playerid) >= 105 && GetPlayerSkin(playerid) <= 107) // Grove
	    {
	        for(new stags = Tag; stags < GRAFFITI_MAXIMOS; stags++)
	        {
	       		if (Tag >= GRAFFITI_MAXIMOS-1) return SendClientMessage(playerid,ROJO,"Ya hay demasiados Graffitis pintados.");
	    		new Float:X, Float:Y, Float:Z,Float:A,name[24];
				GetPlayerPos(playerid, X, Y, Z);
				GetPlayerFacingAngle(playerid, A);
				GetPlayerName(playerid,name,24);
				X += (1 * floatsin(-A, degrees));
				Y += (1 * floatcos(-A, degrees));
				TagInfo[stags][tgX] = X;
    			TagInfo[stags][tgY] = Y;
    			TagInfo[stags][tgZ] = Z;
				pintados[playerid] = 1;
				Tag += 1;
    			Spray[stags] = CreateObject(GRAFFITI_GROVE, X, Y, Z, 0.0, 0.0, A+90);
    			GameTextForPlayer(playerid,"~b~~h~pintado!",3000,3);
    			PlayerPlaySound(playerid,1057,0,0,0);
    			strmid(TagInfo[stags][tgSprayer], name, 0, strlen(name),128);
    			printf("[TAG] %s - %d",TagInfo[stags][tgSprayer],stags);
    			break;
			}
		}

        if (GetPlayerSkin(playerid) >= 269 && GetPlayerSkin(playerid) <= 271) // Grove
	    {
	        for(new stags = Tag; stags < GRAFFITI_MAXIMOS; stags++)
	        {
	       		if (Tag >= GRAFFITI_MAXIMOS-1) return SendClientMessage(playerid,ROJO,"Ya hay demasiados Graffitis pintados.");
	    		new Float:X, Float:Y, Float:Z,Float:A,name[24];
				GetPlayerPos(playerid, X, Y, Z);
				GetPlayerFacingAngle(playerid, A);
				GetPlayerName(playerid,name,24);
				X += (1 * floatsin(-A, degrees));
				Y += (1 * floatcos(-A, degrees));
				TagInfo[stags][tgX] = X;
    			TagInfo[stags][tgY] = Y;
    			TagInfo[stags][tgZ] = Z;
				pintados[playerid] = 1;
				Tag += 1;
    			Spray[stags] = CreateObject(GRAFFITI_GROVE, X, Y, Z, 0.0, 0.0, A+90);
    			GameTextForPlayer(playerid,"~b~~h~pintado!",3000,3);
    			PlayerPlaySound(playerid,1057,0,0,0);
    			strmid(TagInfo[stags][tgSprayer], name, 0, strlen(name),128);
    			printf("[TAG] %s - %d",TagInfo[stags][tgSprayer],stags);
    			break;
			}
		}
        if (GetPlayerSkin(playerid) == 184 && GetPlayerSkin(playerid) == 47) // Vagos
	    {
	        for(new stags = Tag; stags < GRAFFITI_MAXIMOS; stags++)
	        {
	       		if (Tag >= GRAFFITI_MAXIMOS-1) return SendClientMessage(playerid,ROJO,"Ya hay demasiados Graffitis pintados.");
	    		new Float:X, Float:Y, Float:Z,Float:A,name[24];
				GetPlayerPos(playerid, X, Y, Z);
				GetPlayerFacingAngle(playerid, A);
				GetPlayerName(playerid,name,24);
				X += (1 * floatsin(-A, degrees));
				Y += (1 * floatcos(-A, degrees));
				TagInfo[stags][tgX] = X;
    			TagInfo[stags][tgY] = Y;
    			TagInfo[stags][tgZ] = Z;
				pintados[playerid] = 1;
				Tag += 1;
    			Spray[stags] = CreateObject(GRAFFITI_VAGO, X, Y, Z, 0.0, 0.0, A+90);
    			GameTextForPlayer(playerid,"~b~~h~pintado!",3000,3);
    			PlayerPlaySound(playerid,1057,0,0,0);
    			strmid(TagInfo[stags][tgSprayer], name, 0, strlen(name),128);
    			printf("[TAG] %s - %d",TagInfo[stags][tgSprayer],stags);
    			break;
			}
		}
		if (GetPlayerSkin(playerid) >= 108 && GetPlayerSkin(playerid) <= 110)// Vagos
		{
	        for(new stags = Tag; stags < GRAFFITI_MAXIMOS; stags++)
	        {
	       		if (Tag >= GRAFFITI_MAXIMOS-1) return SendClientMessage(playerid,ROJO,"Ya hay demasiados Graffitis pintados.");
	    		new Float:X, Float:Y, Float:Z,Float:A,name[24];
				GetPlayerPos(playerid, X, Y, Z);
				GetPlayerFacingAngle(playerid, A);
				GetPlayerName(playerid,name,24);
				X += (1 * floatsin(-A, degrees));
				Y += (1 * floatcos(-A, degrees));
				TagInfo[stags][tgX] = X;
    			TagInfo[stags][tgY] = Y;
    			TagInfo[stags][tgZ] = Z;
				pintados[playerid] = 1;
				Tag += 1;
    			Spray[stags] = CreateObject(GRAFFITI_VAGO, X, Y, Z, 0.0, 0.0, A+90);
    			GameTextForPlayer(playerid,"~b~~h~pintado!",3000,3);
    			PlayerPlaySound(playerid,1057,0,0,0);
    			strmid(TagInfo[stags][tgSprayer], name, 0, strlen(name),128);
    			printf("[TAG] %s - %d",TagInfo[stags][tgSprayer],stags);
    			break;
			}
		}

		if (GetPlayerSkin(playerid) >= 114 && GetPlayerSkin(playerid) <= 116)  // Corona
		{
	        for(new stags = Tag; stags < GRAFFITI_MAXIMOS; stags++)
	        {
	       		if (Tag >= GRAFFITI_MAXIMOS-1) return SendClientMessage(playerid,ROJO,"Ya hay demasiados Graffitis pintados.");
	    		new Float:X, Float:Y, Float:Z,Float:A,name[24];
				GetPlayerPos(playerid, X, Y, Z);
				GetPlayerFacingAngle(playerid, A);
				GetPlayerName(playerid,name,24);
				X += (1 * floatsin(-A, degrees));
				Y += (1 * floatcos(-A, degrees));
				TagInfo[stags][tgX] = X;
    			TagInfo[stags][tgY] = Y;
    			TagInfo[stags][tgZ] = Z;
				pintados[playerid] = 1;
				Tag += 1;
    			Spray[stags] = CreateObject(GRAFFITI_CORONA, X, Y, Z, 0.0, 0.0, A+90);
    			GameTextForPlayer(playerid,"~b~~h~Pintado!",3000,3);
    			PlayerPlaySound(playerid,1057,0,0,0);
    			strmid(TagInfo[stags][tgSprayer], name, 0, strlen(name),128);
    			printf("[TAG] %s - %d",TagInfo[stags][tgSprayer],stags);
    			break;
			}
		}
        if (GetPlayerSkin(playerid) <= 41)// Corona
	    {
	        for(new stags = Tag; stags < GRAFFITI_MAXIMOS; stags++)
	        {
	       		if (Tag >= GRAFFITI_MAXIMOS-1) return SendClientMessage(playerid,ROJO,"Ya hay demasiados Graffitis pintados.");
	    		new Float:X, Float:Y, Float:Z,Float:A,name[24];
				GetPlayerPos(playerid, X, Y, Z);
				GetPlayerFacingAngle(playerid, A);
				GetPlayerName(playerid,name,24);
				X += (1 * floatsin(-A, degrees));
				Y += (1 * floatcos(-A, degrees));
				TagInfo[stags][tgX] = X;
    			TagInfo[stags][tgY] = Y;
    			TagInfo[stags][tgZ] = Z;
				pintados[playerid] = 1;
				Tag += 1;
    			Spray[stags] = CreateObject(GRAFFITI_CORONA, X, Y, Z, 0.0, 0.0, A+90);
    			GameTextForPlayer(playerid,"~b~~h~pintado!",3000,3);
    			PlayerPlaySound(playerid,1057,0,0,0);
    			strmid(TagInfo[stags][tgSprayer], name, 0, strlen(name),128);
    			printf("[TAG] %s - %d",TagInfo[stags][tgSprayer],stags);
    			break;
			}
		}
        if (GetPlayerSkin(playerid) >= 173 && GetPlayerSkin(playerid) <= 175)// Corona
	    {
	        for(new stags = Tag; stags < GRAFFITI_MAXIMOS; stags++)
	        {
	       		if (Tag >= GRAFFITI_MAXIMOS-1) return SendClientMessage(playerid,ROJO,"Ya hay demasiados Graffitis pintados.");
	    		new Float:X, Float:Y, Float:Z,Float:A,name[24];
				GetPlayerPos(playerid, X, Y, Z);
				GetPlayerFacingAngle(playerid, A);
				GetPlayerName(playerid,name,24);
				X += (1 * floatsin(-A, degrees));
				Y += (1 * floatcos(-A, degrees));
				TagInfo[stags][tgX] = X;
    			TagInfo[stags][tgY] = Y;
    			TagInfo[stags][tgZ] = Z;
				pintados[playerid] = 1;
				Tag += 1;
    			Spray[stags] = CreateObject(GRAFFITI_CORONA, X, Y, Z, 0.0, 0.0, A+90);
    			GameTextForPlayer(playerid,"~b~~h~pintado!",3000,3);
    			PlayerPlaySound(playerid,1057,0,0,0);
    			strmid(TagInfo[stags][tgSprayer], name, 0, strlen(name),128);
    			printf("[TAG] %s - %d",TagInfo[stags][tgSprayer],stags);
    			break;
			}
		}
	}
	return 1;
}

stock PlayerToPoint(playerid,Float:radi, Float:px, Float:py, Float:pz)
{
    if(IsPlayerConnected(playerid))
	{
		new Float:x, Float:y, Float:z;
		new Float:ox, Float:oy, Float:oz;
		GetPlayerPos(playerid, ox, oy, oz);
		x = (ox -px);
		y = (oy -py);
		z = (oz -pz);
		if (((x < radi) && (x > -radi)) && ((y < radi) && (y > -radi)) && ((z < radi) && (z > -radi))) return 1;
	}
	return 0;
}