SA-MP Forums

Go Back   SA-MP Forums > Non-English > Languages > Español/Spanish

 
 
Thread Tools Display Modes
Old 05/11/2016, 12:46 AM   #1
SilverGamingYT
Banned
 
Join Date: Aug 2016
Posts: 28
Reputation: 0
Default [Ayuda] Porque sucede esto

Hola, hoy les queria decir si porfavor alguien me ayuda a solucionar esto. El problema es que yo quiero realizar un sistema de muerte estilo GTA V, lo que hice fue unos texdraws, pero quiero saber como hago para que al morir les salga el texdraw y el nombre del jugador que los asesino, gracias!

Aqui el codigo:

Code:
#include <a_samp>
#if defined FILTERSCRIPT

//news
new muerte
new Text:TDEditor_PTD[MAX_PLAYERS][3];
//
public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Blank Filterscript by your name here");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

#else

main()
{
	print("\n----------------------------------");
	print(" Blank Gamemode by your name here");
	print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
	TDEditor_PTD[playerid][0] = CreatePlayerTextDraw(playerid, 405.500000, 186.266723, "TE_HA_MATADO");
	PlayerTextDrawLetterSize(playerid, TDEditor_PTD[playerid][0], 0.434400, 3.250136);
	PlayerTextDrawAlignment(playerid, TDEditor_PTD[playerid][0], 2);
	PlayerTextDrawColor(playerid, TDEditor_PTD[playerid][0], -1);
	PlayerTextDrawSetShadow(playerid, TDEditor_PTD[playerid][0], 1);
	PlayerTextDrawSetOutline(playerid, TDEditor_PTD[playerid][0], 0);
	PlayerTextDrawBackgroundColor(playerid, TDEditor_PTD[playerid][0], 255);
	PlayerTextDrawFont(playerid, TDEditor_PTD[playerid][0], 2);
	PlayerTextDrawSetProportional(playerid, TDEditor_PTD[playerid][0], 0);
	PlayerTextDrawSetShadow(playerid, TDEditor_PTD[playerid][0], 1);
	PlayerTextDrawSetSelectable(playerid, TDEditor_PTD[playerid][0], true);

	TDEditor_PTD[playerid][1] = CreatePlayerTextDraw(playerid, -10.799992, 134.000030, "box");
	PlayerTextDrawLetterSize(playerid, TDEditor_PTD[playerid][1], 0.000000, 16.159999);
	PlayerTextDrawTextSize(playerid, TDEditor_PTD[playerid][1], 640.000000, 0.000000);
	PlayerTextDrawAlignment(playerid, TDEditor_PTD[playerid][1], 1);
	PlayerTextDrawColor(playerid, TDEditor_PTD[playerid][1], -1523963137);
	PlayerTextDrawUseBox(playerid, TDEditor_PTD[playerid][1], 1);
	PlayerTextDrawBoxColor(playerid, TDEditor_PTD[playerid][1], 8388863);
	PlayerTextDrawSetShadow(playerid, TDEditor_PTD[playerid][1], 0);
	PlayerTextDrawSetOutline(playerid, TDEditor_PTD[playerid][1], 0);
	PlayerTextDrawBackgroundColor(playerid, TDEditor_PTD[playerid][1], 41215);
	PlayerTextDrawFont(playerid, TDEditor_PTD[playerid][1], 2);
	PlayerTextDrawSetProportional(playerid, TDEditor_PTD[playerid][1], 1);
	PlayerTextDrawSetShadow(playerid, TDEditor_PTD[playerid][1], 0);

	TDEditor_PTD[playerid][2] = CreatePlayerTextDraw(playerid, -47.600006, 125.039985, "box");
	PlayerTextDrawLetterSize(playerid, TDEditor_PTD[playerid][2], 0.000000, 1.199998);
	PlayerTextDrawTextSize(playerid, TDEditor_PTD[playerid][2], 643.000000, 0.000000);
	PlayerTextDrawAlignment(playerid, TDEditor_PTD[playerid][2], 1);
	PlayerTextDrawColor(playerid, TDEditor_PTD[playerid][2], 65535);
	PlayerTextDrawUseBox(playerid, TDEditor_PTD[playerid][2], 1);
	PlayerTextDrawBoxColor(playerid, TDEditor_PTD[playerid][2], -1061109505);
	PlayerTextDrawSetShadow(playerid, TDEditor_PTD[playerid][2], 0);
	PlayerTextDrawSetOutline(playerid, TDEditor_PTD[playerid][2], 0);
	PlayerTextDrawBackgroundColor(playerid, TDEditor_PTD[playerid][2], 255);
	PlayerTextDrawFont(playerid, TDEditor_PTD[playerid][2], 1);
	PlayerTextDrawSetProportional(playerid, TDEditor_PTD[playerid][2], 1);
	PlayerTextDrawSetShadow(playerid, TDEditor_PTD[playerid][2], 0);
	return 1;
}

public OnGameModeExit()
{
	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)
{
  new muerte[32];
  format(muerte, 32, "Haz sido asesinado por: %d", playerid);
  SendClientMessage(playerid, 0xFF0000AA, muerte);
  TextDrawShowForPlayer(playerid, TDEditor_PTD);
  return 1;
}

public OnVehicleSpawn(vehicleid)
{
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	return 1;
}

public OnPlayerText(playerid, text[])
{
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	return 1;
}

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;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	return 1;
}
!MUCHAS GRACIAS!
SilverGamingYT is offline  
Old 05/11/2016, 01:09 AM   #2
Ner0x96
Banned
 
Join Date: Oct 2014
Posts: 75
Reputation: 15
Default Respuesta: [Ayuda] Porque sucede esto

Al final de tu FS utiliza:

PHP Code:
stock GetPName(playerid)
{
    new 
p_name[24];
    
GetPlayerName(playerid,p_name,24);
    return 
p_name;

Y cambia tu OnPlayerDeath, por éste:

PHP Code:
public OnPlayerDeath(playeridkilleridreason)
{
  new 
muerte[48];
  
format(muertesizeof(muerte), "Haz sido asesinado por: %s"GetPName(killerid));
  
SendClientMessage(playerid0xFF0000AAmuerte);
  
TextDrawShowForPlayer(playeridTDEditor_PTD);
  return 
1;

Ner0x96 is offline  
Old 06/11/2016, 02:50 AM   #3
Ner0x96
Banned
 
Join Date: Oct 2014
Posts: 75
Reputation: 15
Default Respuesta: [Ayuda] Porque sucede esto

Quote:
Originally Posted by Ner0x96 View Post
Al final de tu FS utiliza:

PHP Code:
stock GetPName(playerid)
{
    new 
p_name[24];
    
GetPlayerName(playerid,p_name,24);
    return 
p_name;

Y cambia tu OnPlayerDeath, por éste:

PHP Code:
public OnPlayerDeath(playeridkilleridreason)
{
  new 
muerte[48];
  
format(muertesizeof(muerte), "Haz sido asesinado por: %s"GetPName(killerid));
  
SendClientMessage(playerid0xFF0000AAmuerte);
  
TextDrawShowForPlayer(playeridTDEditor_PTD);
  return 
1;

Te dije que pruebes ésto, pero tuve un fallo como Enzo que fué no ver que usabas varios TDs lel..

Así que haz lo mismo que dije pero con éste onplayerdeath:

PHP Code:
public OnPlayerDeath(playeridkilleridreason)
{
  new 
muerte[48];
  
format(muertesizeof(muerte), "Haz sido asesinado por: %s"GetPName(killerid));
  
SendClientMessage(playerid0xFF0000AAmuerte);
  for(new 
i=0!= 3i++) TextDrawShowForPlayer(playeridTDEditor_PTD[i]);
  return 
1;

Ner0x96 is offline  
Old 05/11/2016, 01:11 AM   #4
Swedky
Banned
 
Join Date: Jun 2013
Location: Argentina.
Posts: 2,076
Reputation: 827
Default Respuesta: [Ayuda] Porque sucede esto

Con la función GetPlayerName: finalmente quedaría así:

pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
  new muerte[50], name[MAX_PLAYER_NAME]; // la variable "name" guardará el nombre del jugador que mató
    GetPlayerName(killerid, name, sizeof(name)); // Acá almacenamos el nombre del jugador que mató, tene en cuenta que usamos el valor "killerid" y no "playerid".
  format(muerte, sizeof(muerte), "Haz sido asesinado por: %s(%d)", name, playerid);
  SendClientMessage(playerid, 0xFF0000AA, muerte);
  TextDrawShowForPlayer(playerid, TDEditor_PTD);
  return 1;
}

Aumenté el tamaño de muerte así se podrá almacenar todo el texto
Swedky is offline  
Old 05/11/2016, 03:43 AM   #5
SilverGamingYT
Banned
 
Join Date: Aug 2016
Posts: 28
Reputation: 0
Default Re: [Ayuda] Porque sucede esto

Pero tengo un problema, Enzo hice lo que dijiste pero me tira algunos errores :c

Code:
C:\Users\JONATAN\Desktop\diego\LatinGames RP 2.0\filterscripts\muerte.pwn(34) : error 017: undefined symbol "TDEditor_PTD"
C:\Users\JONATAN\Desktop\diego\LatinGames RP 2.0\filterscripts\muerte.pwn(34) : error 017: undefined symbol "playerid"
C:\Users\JONATAN\Desktop\diego\LatinGames RP 2.0\filterscripts\muerte.pwn(34) : error 029: invalid expression, assumed zero
C:\Users\JONATAN\Desktop\diego\LatinGames RP 2.0\filterscripts\muerte.pwn(34) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
SilverGamingYT is offline  
Old 05/11/2016, 05:17 AM   #6
Swedky
Banned
 
Join Date: Jun 2013
Location: Argentina.
Posts: 2,076
Reputation: 827
Default Respuesta: [Ayuda] Porque sucede esto

Esos problemas te aparecen porque:

1. Intentas crear los TDs en OnGameModeInit, lo tendrías que crear en OnPlayerConnect.
2. Creas la variable muerte 2 veces.
3. No le asignas un índice al array TDEditor_PTD cuando intentas mostrar el TD al jugador.
4. Los Player-TextDraws no son los mismos que los TextDraw normales y se utilizan diferentes funciones para manejarlos.

Acá esta arreglado:


Code:
#include <a_samp>


static PlayerText:TDEditor_PTD[MAX_PLAYERS][3]; // Se usa el tag "PlayerText:"


public OnPlayerConnect(playerid) // Es llamado cuando un jugador se conecta al servidor
{
	TDEditor_PTD[playerid][0] = CreatePlayerTextDraw(playerid, 405.500000, 186.266723, "TE HA MATADO");
	PlayerTextDrawLetterSize(playerid, TDEditor_PTD[playerid][0], 0.434400, 3.250136);
	PlayerTextDrawAlignment(playerid, TDEditor_PTD[playerid][0], 2);
	PlayerTextDrawColor(playerid, TDEditor_PTD[playerid][0], -1);
	PlayerTextDrawSetShadow(playerid, TDEditor_PTD[playerid][0], 1);
	PlayerTextDrawSetOutline(playerid, TDEditor_PTD[playerid][0], 0);
	PlayerTextDrawBackgroundColor(playerid, TDEditor_PTD[playerid][0], 255);
	PlayerTextDrawFont(playerid, TDEditor_PTD[playerid][0], 2);
	PlayerTextDrawSetProportional(playerid, TDEditor_PTD[playerid][0], 0);
	PlayerTextDrawSetShadow(playerid, TDEditor_PTD[playerid][0], 1);
	PlayerTextDrawSetSelectable(playerid, TDEditor_PTD[playerid][0], true);

	TDEditor_PTD[playerid][1] = CreatePlayerTextDraw(playerid, -10.799992, 134.000030, "_"); // Si lo dejamos en blanco, el cliente producirá un crash.
	PlayerTextDrawLetterSize(playerid, TDEditor_PTD[playerid][1], 0.000000, 16.159999);
	PlayerTextDrawTextSize(playerid, TDEditor_PTD[playerid][1], 640.000000, 0.000000);
	PlayerTextDrawAlignment(playerid, TDEditor_PTD[playerid][1], 1);
	PlayerTextDrawColor(playerid, TDEditor_PTD[playerid][1], -1523963137);
	PlayerTextDrawUseBox(playerid, TDEditor_PTD[playerid][1], 1);
	PlayerTextDrawBoxColor(playerid, TDEditor_PTD[playerid][1], 8388863);
	PlayerTextDrawSetShadow(playerid, TDEditor_PTD[playerid][1], 0);
	PlayerTextDrawSetOutline(playerid, TDEditor_PTD[playerid][1], 0);
	PlayerTextDrawBackgroundColor(playerid, TDEditor_PTD[playerid][1], 41215);
	PlayerTextDrawFont(playerid, TDEditor_PTD[playerid][1], 2);
	PlayerTextDrawSetProportional(playerid, TDEditor_PTD[playerid][1], 1);
	PlayerTextDrawSetShadow(playerid, TDEditor_PTD[playerid][1], 0);

	TDEditor_PTD[playerid][2] = CreatePlayerTextDraw(playerid, -47.600006, 125.039985, "_");
	PlayerTextDrawLetterSize(playerid, TDEditor_PTD[playerid][2], 0.000000, 1.199998);
	PlayerTextDrawTextSize(playerid, TDEditor_PTD[playerid][2], 643.000000, 0.000000);
	PlayerTextDrawAlignment(playerid, TDEditor_PTD[playerid][2], 1);
	PlayerTextDrawColor(playerid, TDEditor_PTD[playerid][2], 65535);
	PlayerTextDrawUseBox(playerid, TDEditor_PTD[playerid][2], 1);
	PlayerTextDrawBoxColor(playerid, TDEditor_PTD[playerid][2], -1061109505);
	PlayerTextDrawSetShadow(playerid, TDEditor_PTD[playerid][2], 0);
	PlayerTextDrawSetOutline(playerid, TDEditor_PTD[playerid][2], 0);
	PlayerTextDrawBackgroundColor(playerid, TDEditor_PTD[playerid][2], 255);
	PlayerTextDrawFont(playerid, TDEditor_PTD[playerid][2], 1);
	PlayerTextDrawSetProportional(playerid, TDEditor_PTD[playerid][2], 1);
	PlayerTextDrawSetShadow(playerid, TDEditor_PTD[playerid][2], 0);
	return 1;
}


public OnPlayerSpawn(playerid)
{
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
  	new muerte[50], name[MAX_PLAYER_NAME]; // la variable "name" guardará el nombre del jugador que mató
        GetPlayerName(killerid, name, sizeof(name)); // Acá almacenamos el nombre del jugador que mató, tene en cuenta que usamos el valor "killerid" y no "playerid".
  	format(muerte, sizeof(muerte), "Haz sido asesinado por: %s(%d)", name, playerid);
  	SendClientMessage(playerid, 0xFF0000AA, muerte);
  	
  	PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][0]); // PlayerTextDrawShow maneja los player-textdraws - Le asignamos el valor de un índice
  	PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][0]);
  	PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][0]);
  	return 1;
}
Prueba el código y creo que te funcionará pero no creo que lo haga lo que realmente quieres que haga. Si es así, dímelo
Swedky is offline  
Old 05/11/2016, 12:48 PM   #7
SilverGamingYT
Banned
 
Join Date: Aug 2016
Posts: 28
Reputation: 0
Default Re: [Ayuda] Porque sucede esto

Gracias ya no tengo errores ni nada, pero mira, al morir solo sale el mensaje con el cual yo tenia el sistema normal

http://imgur.com/a/sjAnQ
SilverGamingYT is offline  
Old 05/11/2016, 03:13 PM   #8
Swedky
Banned
 
Join Date: Jun 2013
Location: Argentina.
Posts: 2,076
Reputation: 827
Default Respuesta: [Ayuda] Porque sucede esto

Es porque cuando mueres tú solo (o sea, nadie te asesinó), killerid será igual a INVALID_PLAYER_ID o sea a 65335 que sería una ID inválida, por éso te sale un nombre en blanco.

Era ésa tu duda?
Swedky is offline  
Old 05/11/2016, 07:05 PM   #9
SilverGamingYT
Banned
 
Join Date: Aug 2016
Posts: 28
Reputation: 0
Default Re: [Ayuda] Porque sucede esto

Si, pero si alguien me mata entonces si me saldra el texdraw?. Gracias :3. Oye tu ya tienes un proyecto?
SilverGamingYT is offline  
Old 05/11/2016, 07:16 PM   #10
Swedky
Banned
 
Join Date: Jun 2013
Location: Argentina.
Posts: 2,076
Reputation: 827
Default Respuesta: [Ayuda] Porque sucede esto

Ups, error mío. Mira, he mostrado el mismo TD 3 veces jaja, tendrías que cambiarle el índice a 0, 1 y 2:

pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID) // Verificamos que sea una ID conectada
    {
        new muerte[50], name[MAX_PLAYER_NAME]; // la variable "name" guardará el nombre del jugador que mató
        GetPlayerName(killerid, name, sizeof(name)); // Acá almacenamos el nombre del jugador que mató, tene en cuenta que usamos el valor "killerid" y no "playerid".
        format(muerte, sizeof(muerte), "Haz sido asesinado por: %s(%d)", name, killerid); // Era "killerid", no "playerid"
        SendClientMessage(playerid, 0xFF0000AA, muerte);

        PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][0]); // PlayerTextDrawShow maneja los player-textdraws - Le asignamos el valor de un índice
        PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][1]); // Aquí estaban mis errores
        PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][2]);
    }
    return 1;
}
(lee las notas)

Si quieres probar cómo quedaría:

pawn Code:
CMD:ondeath(playerid)
{
    OnPlayerDeath(playerid, playerid, 31);
    return 1;
}

Éso llamará OnPlayerDeath con los parámetros:
1. playerid = tu ID
2. killerid = tu ID
3. reason = una M4

Quote:
Oye tu ya tienes un proyecto?
Sí, perdón
Swedky is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 10:20 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.