SA-MP Forums Archive
Need help with some stuff. - 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: Need help with some stuff. (/showthread.php?tid=166926)



Need help with some stuff. - Snipa - 10.08.2010

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


Re: Need help with some stuff. - [HUN]Jaki - 10.08.2010

Use a gametext!

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

%s inserts a string. Use %i for playerid!


Re: Need help with some stuff. - r0b - 10.08.2010

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"



Re: Need help with some stuff. - Snipa - 10.08.2010

and what do the numbers in the [ and ] represent?


Re: Need help with some stuff. - JaTochNietDan - 10.08.2010

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.


Re: Need help with some stuff. - Snipa - 10.08.2010

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.


Re: Need help with some stuff. - Mike_Peterson - 10.08.2010

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();


Re: Need help with some stuff. - Snipa - 10.08.2010

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


Re: Need help with some stuff. - [L3th4l] - 10.08.2010

Well, you can do something like:

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


Re: Need help with some stuff. - Snipa - 11.08.2010

Ah thanks