SA-MP Forums Archive
Problem at the beginning of writing code - 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: Problem at the beginning of writing code (/showthread.php?tid=642787)



Problem at the beginning of writing code - friderik - 07.10.2017

Hello, I am new in programming and I have first problem. I write simply thing that will give player money on spawn with some text with it but it doesn't work.. Please help!



https://pastebin.com/AhcGJkhM


Re: Problem at the beginning of writing code - Fratello - 07.10.2017

It works!

I've tested it. Can you check again? Maybe you have misspelled game mode name.

EDIT: You don't have to use getplayername to get player's name. There is a correct way to do it.
Код HTML:
public OnPlayerSpawn(playerid)
{
    new Player_Name[MAX_PLAYER_NAME];
    GivePlayerMoney(playerid, START_MONEY);

    new string[64];
    format(string, sizeof(string), "Welcome %s, take that $500 for start!", Player_Name);
    SendClientMessage(playerid, 0xFFFF00FF, string);
    return 1;
}



Re: Problem at the beginning of writing code - Steve57 - 07.10.2017

The code is clean and should work


Re: Problem at the beginning of writing code - Marricio - 07.10.2017

Change this:

Код:
format(string, sizeof(string), "Welcome %s, take that $500 for start!", Player_Name);
To this:

Код:
format(string, sizeof(string), "Welcome %s, take that $%d for start!", Player_Name, START_MONEY);
Now your start money value is totally dynamic.


Re: Problem at the beginning of writing code - friderik - 07.10.2017

I have correct gamemod in cfg, what else could be wrong? :/ Code works only on server console but not in game.


Re: Problem at the beginning of writing code - Steve57 - 07.10.2017

It's working for me


Re: Problem at the beginning of writing code - Fratello - 07.10.2017

Um a bit weird question but have you compiled your gamemode?


Re: Problem at the beginning of writing code - friderik - 07.10.2017

Quote:
Originally Posted by Fratello
Посмотреть сообщение
Um a bit weird question but have you compiled your gamemode?
Yes No errors there, and loading correct map that I am editing.


Re: Problem at the beginning of writing code - Mohaaaaaaaaaaa - 07.10.2017

Compile it with pawno


Re: Problem at the beginning of writing code - Meller - 07.10.2017

Quote:
Originally Posted by Fratello
Посмотреть сообщение
It works!

I've tested it. Can you check again? Maybe you have misspelled game mode name.

EDIT: You don't have to use getplayername to get player's name. There is a correct way to do it.
Код HTML:
public OnPlayerSpawn(playerid)
{
    new Player_Name[MAX_PLAYER_NAME];
    GivePlayerMoney(playerid, START_MONEY);

    new string[64];
    format(string, sizeof(string), "Welcome %s, take that $500 for start!", Player_Name);
    SendClientMessage(playerid, 0xFFFF00FF, string);
    return 1;
}
Are you stupid or just stupid?