Python code to send a private message

Hello there
Im trying to call a Python function to send a message to a character when a specific player spawns.
Cuz handle_event lacks this function
ive seen this

but its doesnt work

i wrote this :


from phBot import *
import phBotChat

player = 'CharName'

def player_spawn():
	global player
	if len(player) > 0:
		phBotChat.Private(player, 'player is here')

log('[%s] Loaded' % __name__)


i need help
i will appreciate any hints
thanks in advance.

That example function is for use in a condition.

the only thing you could do is something like this… obviously replace PlayerName with a char you want
image

The player variable in your python code is just who the message is sent to.

1 Like

Thanks for the help. I did this

asdfwe

but where to put this code?

from phBot import *
import phBotChat

player = 'CharName'

def player_spawn():
	global player
	if len(player) > 0:
		phBotChat.Private(player, 'player is here')

log('[%s] Loaded' % __name__)

thanks in advance.

In a .py file inside your plugin folder

1 Like

Thanks man. Really appreciated.

Another question please @DeRidder14

i need to make a sleep time so it sends a message every 60 seconds for an example.

i made this:

from phBot import *
import phBotChat
import time

player = 'charname'

def player_spawn():
	time.sleep(60)
	global player
	if len(player) > 0:
		phBotChat.Private(player, 'message')

log('[%s] Loaded' % __name__)

but it prevents the char from botting.
So how to make a sleep time without stopping attack ?

Also why when i use Chat conditions (party-union-guild) it sends messages every second. Is theres a way to use chat conditions with an interval time?
Thanks. I really appreciate ur help.

Add delays in the condition not the function. There is a wait you can add to the condition… this will solve both of your questions

aasdasd

idk why its not working!
am i doing it wrong?

wait not time elapsed…

erwervv

hmm… same issue
char. freezes cuz of wait time.
how to make it without stopping attack ?

Any hint please?
I really appreciate ur time
Thanks in advance.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.