SA-MP Forums Archive
Variable text displayed - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Variable text displayed (/showthread.php?tid=68510)



Variable text displayed - Property_Control - 11.03.2009

Alright, now, if some one kills some one, i want it to display "Killer's name Killed Killed Name"
I've got some thing like

public OnPlayerDeath(playerid, killerid, reason)
{
GameTextForPlayer(playerid, "Wasted!", 3500, 2);
SetPlayerWantedLevel(killerid,7);
GetPlayerName(killerid, killername);
SendClientMessageToAll(0x00EEEE, killername);
return 1;
}

How can i get it to display the killer's name, then the person's name who was killed?

I just gotta get the basics down and i'll be able to do this with out any assistance XD


Re: Variable text displayed - Norn - 11.03.2009

Quote:
Originally Posted by Property_Control
Alright, now, if some one kills some one, i want it to display "Killer's name Killed Killed Name"
I've got some thing like

public OnPlayerDeath(playerid, killerid, reason)
{
GameTextForPlayer(playerid, "Wasted!", 3500, 2);
SetPlayerWantedLevel(killerid,7);
GetPlayerName(killerid, killername);
SendClientMessageToAll(0x00EEEE, killername);
return 1;
}

How can i get it to display the killer's name, then the person's name who was killed?

I just gotta get the basics down and i'll be able to do this with out any assistance XD
GetPlayerName, Killerid, Playerid.


Re: Variable text displayed - Property_Control - 11.03.2009

Yea, but how do i display it?


Re: Variable text displayed - Pyrokid - 11.03.2009

Put this at the top of your script as it is very useful.
pawn Код:
stock PlayerName(playerid) {
 new name[16];
 GetPlayerName(playerid, name, sizeof(name));
 return name;
}
And here is the code you want.
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new string[128];
    format(string,sizeof(string),"%s wasted %s!",PlayerName(killerid),PlayerName(playerid));
    SetPlayerWantedLevel(killerid,7);
    SendClientMessageToAll(0x00EEEE, string);
    return 1;
}
Also, I'm pretty sure the most wanted level you can get is 6.


Re: Variable text displayed - Property_Control - 11.03.2009

Thanks! but mind explaining what all that %s stuff is? i have a good guess but i'm not 100% sure.


Re: Variable text displayed - Pyrokid - 11.03.2009

https://sampwiki.blast.hk/wiki/Format

That link explains it all.


Re: Variable text displayed - Property_Control - 11.03.2009

Rofl, the function's not working,

Quote:

C:\Documents and Settings\PROPCO\My Documents\samp02Xserver.win32\gamemodes\test.pwn(8 7) : error 017: undefined symbol "PlayerName"

I'm starting to regret learning this, PAWNO should be more forgiving like PHP...


Re: Variable text displayed - Pyrokid - 11.03.2009

Where is it saying undefined? Paste line 87 please.

Edit: I hope you pasted that function above or below OnPlayerDeath but not inside of it..

Edit 2: I just compiled it and it worked perfectly. You must have misplaced something.


Re: Variable text displayed - Property_Control - 11.03.2009

Pasted it below #include <a_samp> and #if defined FILTERSCRIPT, and line 87 is
Quote:

format(string,sizeof(string),"%s wasted %s!",PlayerName(killerid),PlayerName(playerid));




Re: Variable text displayed - Pyrokid - 11.03.2009

Put all functions below main().

pawn Код:
main()
{
    print("\n----------------------------------");
    print(" Your gamemode");
    print("----------------------------------\n");
}

//All functions go below main().