Mennims
Active member
- Joined
- Mar 18, 2014
- Messages
- 41
- Reaction score
- 0
So I've been stuck on this script for the last 4 fucking days.
It's a personal script so I won't share it, but I replicated one of my problems I had so you guys can explain to me what the fuck is wrong with it.
In this demo script it basically tests if the person is in a car, if you are not in a car, it says so. But that doesn't matter. Sorry if it's messy but I just bodged this together quickly as it has some parts of my script in it so I could re-emulate my problem.
Anyway, the label on_new_textline monitors for server messages (Only the ones that the server sends, the ones in chat. For example the incorrect command error, or anything else) and when that gets called the loop in the main label is supposed to exit and give you a message saying it works. Now you might wonder why it's messy, and why I have random variables lying around. Well basically, everytime the server sends me a chat message, on_chat_newline gets called, without fail. Everytime. When it get's called it sets the variabe 4@ to 1, and because it's set to 1, the while loop can now exit and say it works. Great right? Well. Mostly that doesn't work . For example, in the while loop it constantly monitors until 4@ == 1, or until I get a message from the server. Then it exits, but MOSTLY it doesn't detect the change in variable EVEN THOUGH this 4@ = 1 was called in on_chat_textline. Sometimes it works, but you generally have to get spammed server messages before it triggers every now and then. It's completely random wether or not it checks the variable or whatever else is wrong with it. I have noticed, even though 4@ = 1 is called the variable still doesn't change. This is how i test my script. Start a samp server, a local one, doesn't matter which one. connect to it. You'll see a constant "Nope" message being displayed on the screen. Now spam any random command, it doesn't matter what. All we need is for the server to send us a message warning us that its an incorrect command. So spam something like /penis. You will see the nope constantly flash, but every now and then the message that it works will pop up. It's supposed to pop up EVERY TIME i get a message from the server. But it only happens on random, I dont know why and I need help with this. Now I found out how to fix it. I removed all the ifs in my while statement, so it's just an empty statement, and then it works without fail. But as soon as I add the other checks inside it (which I need) it doesn't work properly.
What I don't understand is. If I set the variable 4@ to 1, no matter how lagged the while loop is, it should EVENTUALLY realize that 4@ = 1 and thus it must exit the loop. But what seems to be happening is, even though I'm setting 4@ to 1, it somehow changes back, and only sometimes does it succesfully change. That's just a guess. If you don't understand this I'll call you on skype, my username is Mennims.
Here is my test code
TLDR:
It appears my variable is not changing most of the time, even though it is getting set to 1, it sticks on 0. Only on random chance does it actually work
It's a personal script so I won't share it, but I replicated one of my problems I had so you guys can explain to me what the fuck is wrong with it.
In this demo script it basically tests if the person is in a car, if you are not in a car, it says so. But that doesn't matter. Sorry if it's messy but I just bodged this together quickly as it has some parts of my script in it so I could re-emulate my problem.
Anyway, the label on_new_textline monitors for server messages (Only the ones that the server sends, the ones in chat. For example the incorrect command error, or anything else) and when that gets called the loop in the main label is supposed to exit and give you a message saying it works. Now you might wonder why it's messy, and why I have random variables lying around. Well basically, everytime the server sends me a chat message, on_chat_newline gets called, without fail. Everytime. When it get's called it sets the variabe 4@ to 1, and because it's set to 1, the while loop can now exit and say it works. Great right? Well. Mostly that doesn't work . For example, in the while loop it constantly monitors until 4@ == 1, or until I get a message from the server. Then it exits, but MOSTLY it doesn't detect the change in variable EVEN THOUGH this 4@ = 1 was called in on_chat_textline. Sometimes it works, but you generally have to get spammed server messages before it triggers every now and then. It's completely random wether or not it checks the variable or whatever else is wrong with it. I have noticed, even though 4@ = 1 is called the variable still doesn't change. This is how i test my script. Start a samp server, a local one, doesn't matter which one. connect to it. You'll see a constant "Nope" message being displayed on the screen. Now spam any random command, it doesn't matter what. All we need is for the server to send us a message warning us that its an incorrect command. So spam something like /penis. You will see the nope constantly flash, but every now and then the message that it works will pop up. It's supposed to pop up EVERY TIME i get a message from the server. But it only happens on random, I dont know why and I need help with this. Now I found out how to fix it. I removed all the ifs in my while statement, so it's just an empty statement, and then it works without fail. But as soon as I add the other checks inside it (which I need) it doesn't work properly.
What I don't understand is. If I set the variable 4@ to 1, no matter how lagged the while loop is, it should EVENTUALLY realize that 4@ = 1 and thus it must exit the loop. But what seems to be happening is, even though I'm setting 4@ to 1, it somehow changes back, and only sometimes does it succesfully change. That's just a guess. If you don't understand this I'll call you on skype, my username is Mennims.
Here is my test code
Code:
{$CLEO .cs}
{$INCLUDE SF}
0000: NOP
0@ = 0 //status bit set to 0. Script is on standby
// 1 = Started script
// 2 = In car
1@ = 0 //Location bit set to unknown/incorrect
// 1 = In first fishing location
// 2 = second fishing location
// 3 = sell fish location
2@ = 0 //Chat bit set to unknown
3@ = 1 //Current fish location
4@ = 0
8@ = 0
repeat
wait 500
until SAMP.Available()
0BE3: raknet setup_incoming_rpc_hook @on_new_chatline
:main
while 4@ == 0
wait 5
0AB1: call @incar 0 store_to 27@
0AB1: call @location 0 store_to 30@
if
not 27@ == 0
then
0AD1: show_formatted_text_highpriority "not in vehicle" time 5
jump @main
end
0AD1: show_formatted_text_highpriority "Nope" time 5
end
0AD1: show_formatted_text_highpriority "ERMA GEEERD IT WORRKSS" time 1000
wait 1000
4@ = 0
jump @main
:incar
wait 0 ms
if
actor.Driving($PLAYER_ACTOR)
then
0@ = 2
0AB2: ret 1 0@
else
0@ = 0
//0AD1: show_formatted_text_highpriority "Not in vehicle" time 1000
0AB2: ret 1 0@
end
:location
wait 0 ms
if
00EE: actor $PLAYER_ACTOR sphere 0 near_point 762.4212 -2568.0906 radius 50.0 50.0 in_car
then
5@ = 1
0AB2: ret 1 5@
end
if
00EE: actor $PLAYER_ACTOR sphere 0 near_point 900.0559 -2060.1918 radius 50.0 50.0 in_car
then
5@ = 2
0AB2: ret 1 5@
end
5@ = 2
0AB2: ret 1 5@
:on_new_chatline
wait 0
0BE5: raknet 29@ = get_hook_param PARAM_PACKETID
if
29@ == RPC_ScrClientMessage
then
4@ = 1
end
0BE0: raknet hook_ret true
TLDR:
It appears my variable is not changing most of the time, even though it is getting set to 1, it sticks on 0. Only on random chance does it actually work