SA-MP Forums Archive
How to call a global timer and to randomize server side moneys (points) - 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: How to call a global timer and to randomize server side moneys (points) (/showthread.php?tid=649296)



How to call a global timer and to randomize server side moneys (points) - wallen - 06.02.2018

OnPlayerDeath Callback

PHP код:
    EARNS[playerid] = TextDrawCreate(304.000000116.000000"+ points");
    
TextDrawBackgroundColor(EARNS[playerid], 255);
    
TextDrawFont(EARNS[playerid], 2);
    
TextDrawLetterSize(EARNS[playerid], 0.5200002.200000);
    
TextDrawColor(EARNS[playerid], 227526655);
    
TextDrawSetOutline(EARNS[playerid], 0);
    
TextDrawSetProportional(EARNS[playerid], 1);
    
TextDrawSetShadow(EARNS[playerid], 1); 
PHP код:
    // If player kills someone he will be awarded with +1 point level and +50 respect
    
new killedwho[MAX_PLAYERS];
    
GetPlayerName(playerid,killedwho,sizeof(killedwho)); // Killer's name
    
format(iStringsizeof iString"{9FF781}* You killed %s and took +1 points and +50 respect"killedwho);
    
SendClientMessage(killerid, -1iString);
    
format(iStringsizeof iString"{D8D8D8}(INFO) Respect: %i"pInfo[killerid][Respect]); 
    
SendClientMessage(killerid, -1iString);
    
TextDrawShowForPlayer(playeridEARNS[playerid]); <--- thats the points TD
    SetTimer
("HideTextdraw"5000false);
    
pInfo[killerid][Points] += 1;
    
pInfo[killerid][Respect] += 50;
    
SetPlayerScore(killeridGetPlayerScore(killerid) + 15);
    
pInfo[killerid][Score] += 15;
    
GameTextForPlayer(killerid,"~y~+15"400,4); 
timer

PHP код:
forward HideTextdraw(playerid);
public 
HideTextdraw(playerid)
{
    
TextDrawHideForPlayer(playeridEARNS[playerid]);

Ok so, how to make a global timer that will disappear this EARNS[playerid] Textdraw for everyone? just noticed that the player with id 0 disappears but the id 1 doesnt. Also how do i make randomized points score like 6,10,14,7,9 etc..? I guess that i need to create some cases for do that. Some help how to write the code?


Re: How to call a global timer and to randomize server side moneys (points) - Private200 - 06.02.2018

First of all, you are using a global textdraw and value will change for everybody; I don't know if that was your intention in first place, just letting you know.

Secondly, use SetTimerEx and forward the player id through it.

PHP код:
SetTimerEx("HideTextdraw"5000false"i"playerid); 
You should be fine that way.

EDIT: about the random function; just search the forums before asking.

PHP код:
stock randomEx(minmax)
{    
    
//Credits to ******    
    
new rand random(max-min)+min;    
    return 
rand;
}
// usage
new _randVal randomEx(510); // min value is 5, max is 10; assigned to _randVal 



Re: How to call a global timer and to randomize server side moneys (points) - dani18 - 06.02.2018

Hey @Private2000, in what way or where would the "randomEx" be used?
or this:
Код:
stock minrand (min, max) // By Alex "******" Cole
{
return random (max - min) + min;
}



Re: How to call a global timer and to randomize server side moneys (points) - Private200 - 06.02.2018

Quote:
Originally Posted by dani18
Посмотреть сообщение
Hey @Private2000, in what way or where would the "randomEx" be used?
or this:
Код:
stock minrand (min, max) // By Alex "******" Cole
{
return random (max - min) + min;
}
Place that anywhere in the script, just outside a function. Usage is already in the example I posted above. You can use it anywhere you want.