Non-standard method... - 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: Non-standard method... (
/showthread.php?tid=586714)
Non-standard method... -
swiftyrus - 24.08.2015
The usual way to work with player data is (example) (player = playerid):
Код:
GetPlayerName(player, account[player][Name], MAX_PLAYER_NAME);
GetPlayerIp(player, account[player][IP], 16);
format(some_string, 128, "Player: %s. And his IP: %s", account[player][Name], account[player][IP]);
SendClientMessageToAll(-1, some_string);
But I guess that there is a way to write it like:
Код:
GetPlayerName(player, account.player.Name, MAX_PLAYER_NAME);
GetPlayerIp(player, account.player.IP, 16);
format(some_string, 64, "Player: %s. His IP is:", account.player.Name, account.player.IP);
SendClientMessageToAll(-1, some_string);
I've tried something like this:
Код:
#define account.%0.Name account[%0][Name]
#define account.%0.IP account[%0][IP]
But the compiler isn't like it.
So, the question is: how to make it work?
Thanks.
AW: Non-standard method... -
Nero_3D - 24.08.2015
In my opinion there is no reason to implement different notations from other languages because they don't improve the code at all
The main problem is that there is no fixed delimiter at the end if you use such a notation
But we know the variable names than we can do something similar to your attempt
pawn Код:
#define account.%0. account[%0][account_
#define account_Name Name]
#define account_IP IP]
Re: AW: Non-standard method... -
Logofero - 24.08.2015
Quote:
Originally Posted by Nero_3D
In my opinion there is no reason to implement different notations from other languages because they don't improve the code at all
|
Yes. Since Pawn does not support classes inherit properties of why you need to invent something?
Re: Non-standard method... -
Logofero - 24.08.2015
@swiftyrus
If you need scripting using a similar method
https://sampforum.blast.hk/showthread.php?tid=580064
Re: AW: Non-standard method... -
swiftyrus - 25.08.2015
Quote:
Originally Posted by Nero_3D
In my opinion there is no reason to implement different notations from other languages because they don't improve the code at all
The main problem is that there is no fixed delimiter at the end if you use such a notation
But we know the variable names than we can do something similar to your attempt
pawn Код:
#define account.%0. account[%0][account_
#define account_Name Name] #define account_IP IP]
|
Thank you, I'll try it soon.
Re: Non-standard method... -
Sithis - 25.08.2015
Or use SampSharp, check my signature!