SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 31/07/2019, 08:27 PM   #1
Robson04
Big Clucker
 
Robson04's Avatar
 
Join Date: Aug 2018
Posts: 66
Reputation: 0
Question OnPlayerFinishedDownloading problem

Hi everyone.
I had problem with this callback. In this code (look down, pawn code) OnPlayerFinishedDownloading sometimes don't call. I don't know why this isn't called. I change player virtual world in onplayerconnect because I wanna check if everything is loaded (custom models). I know. This is called when i downloading files BUT what will happened when player has all this files? This callbacks not be called so I changing vw in onplayerconnect (OnPlayerFinishedDownloading is called when player changing virtual world). Help me please.

My code, look this;
pawn Code:
public OnPlayerConnect(playerid)
{
    SetPlayerVirtualWorld(playerid, 100);
    return 1;
}

public OnPlayerFinishedDownloading(playerid, virtualworld)
{
    if(virtualworld == 100)
    {
        printf("debug, callback is called.");
    }
    return 1;
}

I have custom models in 'models' and they are valid.
Robson04 is offline   Reply With Quote
Old 01/08/2019, 02:16 AM   #2
willttoonn
Gangsta
 
willttoonn's Avatar
 
Join Date: Nov 2011
Location: Brazil
Posts: 913
Reputation: 88
Default Re: OnPlayerFinishedDownloading problem

It's not necessary to check if the OnPlayerFinishedDownloading has been called. Everytime when the player connect in your server the SA-MP will be check all models downloaded, if have new models or anyone models downloaded before are missing he will call the download function and use the OnPlayerFinishedDownloading.

Try to change the player world in OnPlayerRequestClass, this function will be call after the SA-MP Models Check.
__________________
Sometimes a captain has to make the unpopular call because that's his responsibility

Advanced Roleplay - Management and Head Developer
Brazilian Hard Roleplay Server


willttoonn is offline   Reply With Quote
Old 01/08/2019, 10:08 AM   #3
Robson04
Big Clucker
 
Robson04's Avatar
 
Join Date: Aug 2018
Posts: 66
Reputation: 0
Default Re: OnPlayerFinishedDownloading problem

Yes, onplayerfinishingdownloading has called if playerid is connect but when I restart server using 'gmx' this callback isnt called.
Robson04 is offline   Reply With Quote
Old 01/08/2019, 10:10 AM   #4
Mugala
High-roller
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 1,167
Reputation: 73
Default Re: OnPlayerFinishedDownloading problem

callback must be called by player, but when server is restarted, player needs to relaunch gta_sa.exe to call this callback again.
I consider to kick everyone before restarting, so they'll be forced to re-launch gta_sa.exe.

PHP Code:
    for(new 0GetPlayerPoolSize(); <= ji++)
    {
        
Kick(i);
    }
    
SendRconCommand("gmx"); 
__________________
Coding in 8 languages including Pawn, C#, C++ and SQL.
Available for hiring.

If you have a coding question or need an assistance in a code, just PM me.
If you want me to create something for you, here is a Discord Mugala#5651

Currently helping Community members in a coding.
Mugala is offline   Reply With Quote
Old 01/08/2019, 10:29 AM   #5
Robson04
Big Clucker
 
Robson04's Avatar
 
Join Date: Aug 2018
Posts: 66
Reputation: 0
Default Re: OnPlayerFinishedDownloading problem

Yes thank you. I mean about this loop. I was changing in past vw and this was not got crashes but this time have crash.
Robson04 is offline   Reply With Quote
Old 01/08/2019, 10:33 AM   #6
Robson04
Big Clucker
 
Robson04's Avatar
 
Join Date: Aug 2018
Posts: 66
Reputation: 0
Default Re: OnPlayerFinishedDownloading problem

Can I somehow avoid this loop? I would like this callback to be performed even at reboot.
But then playerid was not download files after restart when this models id gonna crash. There is no another way. I must kick player.
Robson04 is offline   Reply With Quote
Old 01/08/2019, 10:40 AM   #7
Mugala
High-roller
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 1,167
Reputation: 73
Default Re: OnPlayerFinishedDownloading problem

why you want to avoid that loop? server must be restarted anyway.
__________________
Coding in 8 languages including Pawn, C#, C++ and SQL.
Available for hiring.

If you have a coding question or need an assistance in a code, just PM me.
If you want me to create something for you, here is a Discord Mugala#5651

Currently helping Community members in a coding.
Mugala is offline   Reply With Quote
Old 01/08/2019, 11:29 AM   #8
Robson04
Big Clucker
 
Robson04's Avatar
 
Join Date: Aug 2018
Posts: 66
Reputation: 0
Default Re: OnPlayerFinishedDownloading problem

Quote:
Originally Posted by Mugala View Post
why you want to avoid that loop? server must be restarted anyway.
My statement is pointless. Without throwing the player, it will crash when loading models, because OnPlayerFinishingDownloading does not execute after 'gmx'.

But when I change it, vw will force checking the downloading of models. So you should check again if it has everything downloaded, how do you think?
Is it necessary to restart the game?
Robson04 is offline   Reply With Quote
Old 01/08/2019, 11:39 AM   #9
Mugala
High-roller
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 1,167
Reputation: 73
Default Re: OnPlayerFinishedDownloading problem

Try SetPlayerVirtualWorld twice at OnPlayerConnect than, it'll force to download that models.
It wont cause crash unless models are correct.
__________________
Coding in 8 languages including Pawn, C#, C++ and SQL.
Available for hiring.

If you have a coding question or need an assistance in a code, just PM me.
If you want me to create something for you, here is a Discord Mugala#5651

Currently helping Community members in a coding.
Mugala is offline   Reply With Quote
Old 01/08/2019, 11:45 AM   #10
Robson04
Big Clucker
 
Robson04's Avatar
 
Join Date: Aug 2018
Posts: 66
Reputation: 0
Default Re: OnPlayerFinishedDownloading problem

Quote:
Originally Posted by Mugala View Post
Try SetPlayerVirtualWorld twice at OnPlayerConnect than, it'll force to download that models.
It wont cause crash unless models are correct.
This is works! I will observe it, if it crashes, I will use the loop of which we were thinking. Thanks.
Robson04 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OnPlayerFinishedDownloading not being called on Localhost seanny Scripting Help 2 01/04/2018 12:02 AM
Password Hash Problem & MYSQL Saving Problem Faqahat Scripting Help 3 18/04/2016 12:54 PM
[SOLVED] 3 problem's! (1 problem still unsolved, but stopped solving.) Mechscape Help Archive 9 24/12/2009 09:47 PM


All times are GMT. The time now is 01:12 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.