Need help with some stuff.
#1

Ok so i want when a player dies in my script, the killer gets 1 score and when a player dies, it says like the "WASTED" sign but as in "Noob!"

Here is my OnPlayerDeath:

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SendClientMessage(playerid, COLOR_BRIGHTRED, "You have lost $1000 for dieing!");
    SendClientMessage(killerid, COLOR_GREEN, "Good job on killing %s you got $1000 and 1 score!", playerid);
    GivePlayerMoney(playerid, -1000);
    GivePlayerMoney(killerid, 1000);

    return 1;
}
Yeah i know, its pretty basic stuff and i have no idea how to use the %s thing. Is it like a variable or what? Im really new at scripting. Yeah help would be really appreciated
Reply
#2

Use a gametext!

https://sampwiki.blast.hk/wiki/GameTextForPlayer
https://sampwiki.blast.hk/wiki/GameTextStyle

%s inserts a string. Use %i for playerid!
Reply
#3

But to insert %s and %i and %d and so on in a string you need format:
Код:
new string[64],pname[20];
GetPlayerName(playerid,pname,sizeof pname);
format(string,sizeof string,"your name: %s",pname);
SendClientMessage(playerid,COLOR,string); // if your name is Snipa, it will send: "your name: Snipa"
Reply
#4

and what do the numbers in the [ and ] represent?
Reply
#5

Quote:
Originally Posted by Snipa
Посмотреть сообщение
and what do the numbers in the [ and ] represent?
They represent the length of the array variable. How many bits of information you can store in it.
Reply
#6

OK so here is my OnPlayerDeath:

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new string[64],pname[20];
    GetPlayerName(playerid,pname,sizeof pname);
    format(string,sizeof string,"You killed %s!",pname);
    SendClientMessage(killerid,COLOR_GREEN,string);
   
    new string[50];
    format(string, sizeof(string), "Noob!", playerid);
    GameTextForPlayer(playerid, string, 3000, 2);

    SendClientMessage(killerid, COLOR_GREEN, "You got $1000 and 1 score!");
    SendClientMessage(playerid, COLOR_BRIGHTRED, "You have lost $1000 for dieing!");
    GivePlayerMoney(playerid, -1000);
    GivePlayerMoney(killerid, 1000);

    return 1;
}
When i compile, i get these errors:

pawn Код:
C:\Program Files\Serv\gamemodes\MW2.pwn(103) : error 021: symbol already defined: "string"
C:\Program Files\Serv\gamemodes\MW2.pwn(307) : warning 235: public function lacks forward declaration (symbol "OnSamSiteRestarted")
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
You dont need to worry about the warning, i use a SAM SITE include. So how do i use another string without getting this error that i have already defined "string"?

PS i need the default font for pawno, i was messing around with mine.
Reply
#7

i see the error, look u did new string[64] pname[20]
and on the second thing u did new string[50] delete that one..
you already defined string.. to fix the warning use:
forward OnSamSiteRestarted();
Reply
#8

Ah thanks but i still need help on the score thing!
Reply
#9

Well, you can do something like:

pawn Код:
SetPlayerScore(killerid, GetPlayerScore(killerid)+1);
will give a score to the killer
Reply
#10

Ah thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)