[Plugin] Python
#17

Quote:
Originally Posted by yass0016
Посмотреть сообщение
Why it doesn't work?
And also when I try to compile python.pwn with pawno it can't find the include file in pawno/include

Also there is some problems compiling with Vistual C++ 2010

One more thing. The error above is only with 0.3c, I tried it with 0.3b and it did excute with errors and warnings
I haven't tested it with 0.3c yet, but I think some functions were removed in 0.3c (SetPlayerHoldingObject, ...) and that's the problem. You need to remove (or comment out) these old functions from python.pwn and recompile it. I forgot to include the include file, I'll include it in the next packages. For now, I put it on pastebin: http://pastebin.com/xW3SqrXp
You can ignore the warnings I mentioned in the first post with 0.3b (see that post, if you use 0.3c).

Which errors exactly do you get (or what problems do you have) when trying to compile the plugin? Have you set the Python include and library directories correctly?


Quote:
Originally Posted by Retardedwolf
You should list the advantages comparing Python to Pawn.
Some big advantages of Python are, as already mentioned by mkr, dynamic variables (no predefined type of variables, you can assign anything to any variable; and lists/arrays/dictionaries with variable sizes), and its huge standards library (for many (most) things there are already functions in a Python module). Of course object orientation also is a big advantage.
For example, you can write a player class, which contains any player-specific information and add one global dictionary. Then you can create a new instance of that class whenever a player connects, and add it to the dictionary. When a player disconnects, you can then remove his entry.
Код:
from samp import *

class player(object):
	def __init__(self, playerid):
		self.playerid = playerid
		self.senselessInfo = 123
		# any other needed player variables

players = {}
def OnPlayerConnect(playerid):
	# add a new instance of the player class to the global player dictionary
	players[playerid] = player(playerid)

def OnPlayerDisconnect(playerid, reason):
	# delete that player from the dictionary
	del players[playerid]
Then you can also simply loop through each connected player without checking, if a player is connected 500 times even if there is only 1 player online:
Код:
for pl in players:
	printf("Player %d: %d" % (players[pl].playerid, players[pl].senselessInfo))
And to check, if a playerid is online, you can use:
Код:
if playerid in players:
Reply


Messages In This Thread
Python - by Fabsch - 25.12.2010, 19:37
Re: Python - by [L3th4l] - 25.12.2010, 19:57
Re: Python - by HyperZ - 25.12.2010, 20:24
Re: Python - by Guest3598475934857938411 - 25.12.2010, 20:31
Respuesta: Python - by anonymousx - 25.12.2010, 21:56
Re: Python - by Retardedwolf - 25.12.2010, 22:02
Re: Python - by Mean - 25.12.2010, 22:09
Re: Python - by mkr - 26.12.2010, 08:47
Re: Python - by Wyu - 26.12.2010, 09:00
AW: Python - by Fabsch - 27.12.2010, 18:39
Re: Python - by yass0016 - 29.12.2010, 23:43
Re: Python - by _rAped - 30.12.2010, 00:11
Re: Python - by Lorenc_ - 30.12.2010, 00:28
Re: Python - by TheRob - 30.12.2010, 01:00
Re: Python - by Retardedwolf - 30.12.2010, 01:12
Re: Python - by mkr - 30.12.2010, 08:20
AW: Re: Python - by Fabsch - 30.12.2010, 14:08
Re: Python - by Retardedwolf - 30.12.2010, 19:22
Re: Python - by mkr - 05.01.2011, 22:18
AW: Python - by Fabsch - 06.01.2011, 13:35
Re: Python - by Leeroy. - 06.01.2011, 13:49
Re: Python - by GaGlets(R) - 06.01.2011, 14:47
AW: Python - by Fabsch - 06.01.2011, 15:55
Re: Python - by Wyu - 06.01.2011, 16:37
Re: Python - by ToPhrESH - 09.01.2011, 03:21
Re: Python - by TheYoungCapone - 09.01.2011, 03:50
AW: Re: Python - by Fabsch - 09.01.2011, 18:41
Re: Python - by mkr - 21.05.2011, 02:35
AW: Re: Python - by Fabsch - 21.05.2011, 16:11
Re: Python - by Sfinx_17 - 24.07.2011, 23:01
Re: Python - by GangsTa_ - 25.07.2011, 07:29
AW: Re: Python - by Fabsch - 25.07.2011, 10:38
Re: Python - by Sfinx_17 - 26.07.2011, 18:23
AW: Python - by Fabsch - 28.07.2011, 13:12
Re: Python - by Trenico - 19.01.2012, 22:12
AW: Python - by Fabsch - 20.01.2012, 11:17
Re: Python - by gephaest - 20.01.2012, 22:34
Re: Python - by Deskoft - 20.01.2012, 23:17
AW: Python - by NaS - 20.01.2012, 23:57
Re: Python - by gephaest - 21.01.2012, 08:30
AW: Python - by NaS - 22.01.2012, 00:02
AW: Python - by Fabsch - 22.01.2012, 11:31

Forum Jump:


Users browsing this thread: 1 Guest(s)