Non-standard method...
#1

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.
Reply
#2

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]
Reply
#3

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?
Reply
#4

@swiftyrus
If you need scripting using a similar method https://sampforum.blast.hk/showthread.php?tid=580064
Reply
#5

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.
Reply
#6

Or use SampSharp, check my signature!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)