PDA

View Full Version : I always need help :)


daastle
14/06/2012, 01:09 PM
So basically I want a message to come out when a player kills another player.(Most of it is from a mix of threads, but i cant get it to work , so here it goes :) (yeah Im quite a noob at scripting , its probably simple)



public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid, playerid, reason);
SetPlayerScore(killerid,GetPlayerScore(killerid)+1 );
new weapname[50]; //brought it before the getplayer
new string[128]; //defined a string
GetWeaponName(GetPlayerWeapon(killerid),weapname, sizeof(weapname));
format(string,128,"%s has killed %s with a %s.",killerid,playerid,weapname);
SendClientMessageToAll(0x800000AA, string);
return 1;
}


when someone gets killed , it says "has been killed with a sawn off"

basically i want it to be , for example "daastle (id) has been killed by don2 (id) with a sawn off .

any quit answers anyone? I am quite nooby and dont really understand like the last bit of it , but I would love to have this one :)

pd:and if It isnt asking for too much, I wanted to insert id into my heal cmd , and I want the clientmessagetoall to send the id too , not only the name (right now it says : "daastle has used /heal" , and I wanted it to be "daastle (id) has used heal)

if (strcmp("/heal", cmdtext, true, 10) == 0)
{
new name[24], string[56];
SetPlayerHealth(playerid, 100);
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s (%d) has used /heal", name, playerid);
SendClientMessageToAll(0xFF9900AA, string);
return 1;
}

Maybe Im asking for too much , but I dont understand most of the tutorials because most of them assume I know how what "define" is and stuff.


Thanks alot :) (if you wish to put a timer between heal and heal , please do It :) )

Sorry for all the questions :S

Vince
14/06/2012, 01:16 PM
GetPlayerName. Playerid and killerid only contain the ids.

daastle
14/06/2012, 01:24 PM
GetPlayerName. Playerid and killerid only contain the ids.

Im sorry, but as I said i dont actually understand like specific stuff....

Do you mean I need one to get playername instead of player ID ?

And how do I do that?

newbienoob
14/06/2012, 01:31 PM
public OnPlayerDeath(playerid, killerid, reason)
{
new killername[24],playername[24];
GetPlayerName(playerid,playername,24);//get player's name
GetPlayerName(killerid,killername,24);//get killer's name
SendDeathMessage(killerid, playerid, reason);
SetPlayerScore(killerid,GetPlayerScore(killerid)+1 );
new weapname[50]; //brought it before the getplayer
new string[128]; //defined a string
GetWeaponName(GetPlayerWeapon(killerid),weapname, sizeof(weapname));
format(string,128,"%s(%d) has killed %s(%d) with a %s.",killername,killerid,playername,playerid,weapname) ;
SendClientMessageToAll(0x800000AA, string);
return 1;
}
You forgot to add GetPlayerName..

Revo
14/06/2012, 01:38 PM
GetPlayerName(playerid, playername, sizeof(playername));

or

public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid, playerid, reason);
SetPlayerScore(killerid,GetPlayerScore(killerid)+1 );
new weapname[50]; //brought it before the getplayer
new string[128]; //defined a string
GetWeaponName(GetPlayerWeapon(killerid),weapname, sizeof(weapname));
format(string,128,"%s(%d) has killed %s(%d) with a %s.",PlayerName(killerid),killerid,PlayerName(playerid ),playerid,weapname);
SendClientMessageToAll(0x800000AA, string);
return 1;
}
stock PlayerName(playerid)
{
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
return playername;
}

daastle
14/06/2012, 02:49 PM
Thanks a lot guys. And if someone does , like admin does sethealth 2 0 , then it says "has been killed by" , without anything. anyways to make it say "killed by hand of god" ?