A question again about defining..
#1

So, in the old thread I understood about defining player vars with dot (e.g. Player.Name instead of Player[playerid][Name]). A new question is about defining functions...
For example, we have a standard function, standard callback and one custom function:
Код:
public OnPlayerConnect(playerid)
{
 SendClientMessage(playerid, -1, "Hello!"); //it will be our standard function
}

SetPlayerSomeStuff(playerid) //custom function
{
 SomeFunc();
 SomeFuncElse();
}
I want to write it like (in some place I've also define 'event' (public) and 'player' (playerid)):
Код:
event player.connect()
{
 player.sendMessage(-1, "Hello!");
}

player.setSomeStuff()
{
 SomeFunc();
 SomeFuncElse();
}
It will be good if someone explain me how to make define like that. I mean.. em.. something like that:
Код:
#define %0.connect() OnPlayerConnect(%0)
Thanks.
Reply
#2

Pawn is not an OO language and I don't think it's wise to pretend that it is. You're only making things more difficult for yourself and others reading your code.
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
Pawn is not an OO language and I don't think it's wise to pretend that it is. You're only making things more difficult for yourself and others reading your code.
I know, but I want to try. I have no plans to release my code to the public.

I have a strict source code structure and I will not have the problems with reading my code.
Reply
#4

What do you want to try exactly since PAWN is not object oriented? Its like saying you know that your car is limited to 50km/h and yet you want it to go 100km/h. Not sure if the best example but this is what I came up with on the spot xD.
Reply
#5

Quote:
Originally Posted by rappy93
Посмотреть сообщение
What do you want to try exactly since PAWN is not object oriented?
I want to.. imitate classes, I guess, nothing more. I described this in the examples.
Reply
#6

Quote:
Originally Posted by rappy93
Посмотреть сообщение
What do you want to try exactly since PAWN is not object oriented? Its like saying you know that your car is limited to 50km/h and yet you want it to go 100km/h. Not sure if the best example but this is what I came up with on the spot xD.
More accurately, it's like a car that goes 50km/h and you paint 100km/h on the speedo and pretend you're going faster. It's stupid and pointless.
Reply
#7

It's not perfect...but you can do it like that:

PHP код:
#define event public
#define connect() OnPlayerConnect(playerid)
#define player.sendMessage(%0) SendClientMessage(playerid,%0)
#define func stock
event connect()
{
     
player.sendMessage(-1"Hello!");
}
func setSomeStuff()
{
    return 
1;

Reply
#8

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
It's not perfect...but you can do it like that:

PHP код:
#define event public
#define connect() OnPlayerConnect(playerid)
#define player.sendMessage(%0) SendClientMessage(playerid,%0)
#define func stock
event connect()
{
     
player.sendMessage(-1"Hello!");
}
func setSomeStuff()
{
    return 
1;

Yeah, you understood me, thank you, I will be modify this for myself.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)