What Is Wrong In It - 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)
+--- Thread: What Is Wrong In It (
/showthread.php?tid=610607)
What Is Wrong In It -
CarRamper - 26.06.2016
Код:
new string[ 300 ];
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
SM0 = TextDrawCreate(280.000091, 193.386627, "~w~Welcome To~g~San Fierro ~b~%s");
TextDrawLetterSize(SM0, 0.491600, 1.749333);
TextDrawAlignment(SM0, 2);
TextDrawColor(SM0, -1);
TextDrawSetShadow(SM0, 0);
TextDrawSetOutline(SM0, 1);
TextDrawBackgroundColor(SM0, 51);
TextDrawFont(SM0, 3);
TextDrawSetProportional(SM0, 1);
SM1 = TextDrawCreate(321.599914, 211.306549, "~w~Type ~y~/help ~y~/rules ~w~or ~y~/cmds ~w~for game info");
TextDrawLetterSize(SM1, 0.334000, 1.368533);
TextDrawAlignment(SM1, 2);
TextDrawColor(SM1, -1);
TextDrawSetShadow(SM1, 0);
TextDrawSetOutline(SM1, 1);
TextDrawBackgroundColor(SM1, 51);
TextDrawFont(SM1, 3);
TextDrawSetProportional(SM1, 1);
errors
Код:
C:\Users\Anurag\Desktop\Most Wanted Cops and Robbers v1.1\gamemodes\MWCNR.pwn(2719) : error 017: undefined symbol "playerid"
C:\Users\Anurag\Desktop\Most Wanted Cops and Robbers v1.1\gamemodes\MWCNR.pwn(2739) : error 021: symbol already defined: "string"
Error line
Код:
GetPlayerName(playerid, pName, sizeof(pName));
Re: What Is Wrong In It -
Mencent - 26.06.2016
Hello!
I think this code is in the callback OnGameModeInit and there doesn't exist "playerid".
So, you have to create this textdraw there and update the text in another callback.
In OnGameModeInit:
PHP код:
SM0 = TextDrawCreate(280.000091, 193.386627, "~w~Welcome To~g~San Fierro ~b~%s");
TextDrawLetterSize(SM0, 0.491600, 1.749333);
TextDrawAlignment(SM0, 2);
TextDrawColor(SM0, -1);
TextDrawSetShadow(SM0, 0);
TextDrawSetOutline(SM0, 1);
TextDrawBackgroundColor(SM0, 51);
TextDrawFont(SM0, 3);
TextDrawSetProportional(SM0, 1);
SM1 = TextDrawCreate(321.599914, 211.306549, "~w~Type ~y~/help ~y~/rules ~w~or ~y~/cmds ~w~for game info");
TextDrawLetterSize(SM1, 0.334000, 1.368533);
TextDrawAlignment(SM1, 2);
TextDrawColor(SM1, -1);
TextDrawSetShadow(SM1, 0);
TextDrawSetOutline(SM1, 1);
TextDrawBackgroundColor(SM1, 51);
TextDrawFont(SM1, 3);
TextDrawSetProportional(SM1, 1);
In OnPlayerConnect:
PHP код:
new string[ 300 ];
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(string,sizeof(string),"~w~Welcome to~g~ San Fierro ~b~%s",pName);
TextDrawShowForPlayer(playerid,SM0);
TextDrawSetString(SM0,string);
Tip:
You will update the text with the name so you should use player textdraws (
https://sampwiki.blast.hk/wiki/CreatePlayerTextDraw). So each player can see his / her own name.
If you use the global textdraws each connected player will see the name of the last connected player.
I hope it's understandable.