Problem-Need help - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem-Need help (
/showthread.php?tid=107208)
Problem-Need help -
[XST]O_x - 08.11.2009
Hello,
I've made a /vgod on command which works perfect!
here is the code:
pawn Код:
forward autofixtimer(playerid);
#include <a_samp>
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/carfix on", cmdtext, true, 9) == 0)
{
new Float:health;
new veh;
veh = GetPlayerVehicleID(playerid);
GetVehicleHealth(veh, health);
if(health <500) SetVehicleHealth(veh,1000);
GameTextForPlayer(playerid,"~w~Auto Car Fix ~g~On!",1000,5);
SetTimer("autofixtimer",3000,1);
return 1;
}
return 0;
}
public autofixtimer(playerid)
{
new Float:health;
new veh;
veh = GetPlayerVehicleID(playerid);
GetVehicleHealth(veh, health);
if(health <500) SetVehicleHealth(veh,1000);
return 1;
}
Well,The problem is,That i didn't get how to make a /vgod off command.
So I've tried making something like that:
pawn Код:
if (strcmp("/vgod off", cmdtext, true, 10) == 0)
{
KillTimer(autofixtimer(playerid));
GameTextForPlayer(playerid,"~w~vgod ~r~Off!",1000,5);
return 1;
}
But,I've noticed half of the objects are gone in the game.
So,I went to a map on my server,A Hugejump,With /vgod on,all objects appeared and the /vgod on worked perfect!.
Then i've tried making the same hugejump with /Vgod off,And half of the objects are gone again..
So there's a problem with the /Vgod off command.
May someone fix it?
Thanks in advance.
Re: Problem-Need help -
member - 08.11.2009
You need SetTimerEx.
pawn Код:
#define MAX_SERVER_PLAYERS 27 //change to ur server max player +1
new AutoVehFixTimer[MAX_SERVER_PLAYERS];
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/carfix on", cmdtext, true, 9) == 0)
{
new Float:health;
new veh;
veh = GetPlayerVehicleID(playerid);
GetVehicleHealth(veh, health);
if(health <500) SetVehicleHealth(veh,1000);
GameTextForPlayer(playerid,"~w~Auto Car Fix ~g~On!",1000,5);
AutoVehFixTimer[playerid] = SetTimerEx("autofixtimer", 5000, true, "i", playerid);
return 1;
}
if (strcmp("/vgodoff", cmdtext, true, 8) == 0)
{
GameTextForPlayer(playerid,"~w~Auto Car Fix ~r~Off!",1000,5);
KillTimer(AutoVehFixTimer[playerid]);
return 1;
}
return 0;
}
forward autofixtimer(playerid);
public autofixtimer(playerid)
{
new Float:health;
new veh;
veh = GetPlayerVehicleID(playerid);
GetVehicleHealth(veh, health);
if(health <500) SetVehicleHealth(veh,1000);
return 1;
}
Good Luck
Re: Problem-Need help -
[XST]O_x - 08.11.2009
Quote:
Originally Posted by [B2K
Hustler ]
You need SetTimerEx.
pawn Код:
#define MAX_SERVER_PLAYERS 27 //change to ur server max player +1
new AutoVehFixTimer[MAX_SERVER_PLAYERS];
public OnPlayerCommandText(playerid, cmdtext[]) { if (strcmp("/carfix on", cmdtext, true, 9) == 0) { new Float:health; new veh; veh = GetPlayerVehicleID(playerid); GetVehicleHealth(veh, health); if(health <500) SetVehicleHealth(veh,1000); GameTextForPlayer(playerid,"~w~Auto Car Fix ~g~On!",1000,5); AutoVehFixTimer[playerid] = SetTimerEx("autofixtimer", 5000, true, "i", playerid); return 1; } if (strcmp("/vgodoff", cmdtext, true, 8) == 0) { GameTextForPlayer(playerid,"~w~Auto Car Fix ~r~Off!",1000,5); KillTimer(AutoVehFixTimer[playerid]); return 1; } return 0; } forward autofixtimer(playerid); public autofixtimer(playerid) { new Float:health; new veh; veh = GetPlayerVehicleID(playerid); GetVehicleHealth(veh, health); if(health <500) SetVehicleHealth(veh,1000); return 1; }
Good Luck
|
Thanks but what did you mean in "change to ur server max player +1" ?
You mean like..If i have max 50 players shall i set it to #define MAX_SERVER_PLAYERS 51?
Re: Problem-Need help -
member - 08.11.2009
Quote:
Originally Posted by ►ϻozilla Fir3foж◄
Thanks but what did you mean in "change to ur server max player +1" ?
You mean like..If i have max 50 players shall i set it to #define MAX_SERVER_PLAYERS 51?
|
Yeh thats what i meant. So if for example, your server has a maximum player slot of 25 you would define "MAX_SERVER_PLAYERS" as 26.
You can of course use MAX_PLAYERS, but for improvement in server memory and efficiency i recommend you replace MAX_PLAYERS with MAX_SERVER_PLAYERS throughout your script. (Ctrl+H). ******'s Code Optimisation may help as well.
http://forum.sa-mp.com/index.php?topic=79810.0
Anyways, Good Luck.
Re: Problem-Need help -
[XST]O_x - 08.11.2009
Quote:
Originally Posted by [B2K
Hustler ]
Quote:
Originally Posted by ►ϻozilla Fir3foж◄
Thanks but what did you mean in "change to ur server max player +1" ?
You mean like..If i have max 50 players shall i set it to #define MAX_SERVER_PLAYERS 51?
|
Yeh thats what i meant. So if for example, your server has a maximum player slot of 25 you would define "MAX_SERVER_PLAYERS" as 26.
You can of course use MAX_PLAYERS, but for improvement in server memory and efficiency i recommend you replace MAX_PLAYERS with MAX_SERVER_PLAYERS throughout your script. (Ctrl+H). ******'s Code Optimisation may help as well. http://forum.sa-mp.com/index.php?topic=79810.0
Anyways, Good Luck.
|
Ok thanks i'm going to check xP