SA-MP Forums Archive
A question again about defining.. - 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: A question again about defining.. (/showthread.php?tid=589850)



A question again about defining.. - swiftyrus - 23.09.2015

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.


Re: A question again about defining.. - Vince - 23.09.2015

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.


Re: A question again about defining.. - swiftyrus - 23.09.2015

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.


Re: A question again about defining.. - rappy93 - 23.09.2015

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.


Re: A question again about defining.. - swiftyrus - 23.09.2015

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.


Re: A question again about defining.. - MP2 - 23.09.2015

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.


AW: A question again about defining.. - Kaliber - 23.09.2015

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;




Re: AW: A question again about defining.. - swiftyrus - 24.09.2015

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.