Re: Little coding questions - For general minor queries 5 -
Dayrion - 26.12.2016
Hey. Quick question. Have the ID of the zombie (a dead red man) ? I found only part of him. (
http://dev.prineside.com/en/gtasa_sa.../search/?q=kmb)
Re: Little coding questions - For general minor queries 5 -
Amads - 26.12.2016
Quote:
Originally Posted by Dayrion
|
There's no 'complete' zombie object. I guess they are made using those dead body parts and AttachObjectToObject.
Re: Little coding questions - For general minor queries 5 -
Amads - 26.12.2016
Quote:
Originally Posted by Amads
Does RemoveBuildingForPlayer's limit applies to times RemoveBuildingForPlayer are used, or overal number of objects deleted (when you use one RemoveBuildingForPlayer function to remove more than 1 object in specified range)?
|
bump
Re: Little coding questions - For general minor queries 5 -
jbankss - 27.12.2016
PHP код:
stock GetPlayerHealthArmour(playerid)
{
new Float:total;
total += GetPlayerHealth(playerid);
total += GetPlayerArmour(playerid);
return total; // <--- warning 213: tag mismatch
}
















??


??
Re: Little coding questions - For general minor queries 5 -
Lordzy - 27.12.2016
Quote:
Originally Posted by jbankss
|
Because you're trying to return a
float type variable on a function which expects non-floating type value to be returned. You should add "Float:" tag to the function definition.
pawn Код:
stock Float:GetPlayerHealthArmour(playerid)
Secondly, that's not how you use GetPlayerHealth and GetPlayerArmour. The syntax is GetPlayer<Health/Armour>(playerid, &health/armour).
pawn Код:
new
Float:player_Health,
Float:player_Armour
;
GetPlayerHealth(playerid, player_Health);
GetPlayerArmour(playerid, player_Armour);
player_Health += player_Armour; //Can be considered as the total.
Quote:
Originally Posted by Amads
bump
|
AFAIK it depends on the number of objects removed. The client will start facing few issues once 1000 objects are removed. That's more likely to be the limit.
Re: Little coding questions - For general minor queries 5 -
BEMAmiganimans1r - 28.12.2016
Hi
I want to install this anti cheat
https://sampforum.blast.hk/showthread.php?tid=579963
i copied nex-ac.inc and .lang to pawn/include
but when i write #include <nex-ac> after #include <a-samp>
i have an error
https://i.imgsafe.org/3d0eb83a03.jpg
https://i.imgsafe.org/3d1b5dd8a8.jpg
Thank you
sorry for my bad english
i fix it thank you

Re: Little coding questions - For general minor queries 5 -
ISmokezU - 29.12.2016
I wanna ask something about cells i could be using too much cell or too little cells,first off,a large script that constantly has new string[value]; everywhere isn't it easier to just do new string[7000]; and that would cover everything? but is it too much cell? Also what would happen if i use too much unnecessary cell would the server be laggy or something?
Secondly:
i wanna know how to determine the right amount of cell to be use. In this case:
PHP код:
new string[30];
format(string,sizeof(string),"Wanted Level: %d",GetPlayerWantedLevel(playerid));
SendClientMessage(0,-1,string);"
is that too much cell being used?
Re: Little coding questions - For general minor queries 5 -
Abagail - 29.12.2016
For your first question,
https://sampforum.blast.hk/showthread.php?tid=375180.
For your second question, 16 should be enough cells assuming you're not using wanted levels over 9. You only really need to use the amount of characters you can possibly have + 1. In this case, Wanted Level: 6 would take up 15 characters, add one to account for the null terminator.
Re: Little coding questions - For general minor queries 5 -
ISmokezU - 29.12.2016
Quote:
Originally Posted by Abagail
For your first question, https://sampforum.blast.hk/showthread.php?tid=375180.
For your second question, 16 should be enough cells assuming you're not using wanted levels over 9. You only really need to use the amount of characters you can possibly have + 1. In this case, Wanted Level: 6 would take up 15 characters, add one to account for the null terminator.
|
Oh,thanks i'll go with the very large value and format it where needed.
Re: Little coding questions - For general minor queries 5 -
SickAttack - 29.12.2016
Quote:
Originally Posted by ISmokezU
Oh,thanks i'll go with the very large value and format it where needed.
|
No, the more cells you define, the longer it takes to format it.
Re: Little coding questions - For general minor queries 5 -
Dayrion - 08.01.2017
Quote:
Originally Posted by PrO.GameR
PHP код:
if(!Something) Something=!!SetTimer("SomethingTimer", 1000, false);
|
So I don't understand why he does this on the timer's ID.
Re: Little coding questions - For general minor queries 5 -
PrO.GameR - 08.01.2017
true and false are translated to 1 & 0 in pawn, SetTimer always gives the timerID which is a positive non-zero number, it basically sets Something to true thats all.
Re: Little coding questions - For general minor queries 5 -
Dayrion - 08.01.2017
Quote:
Originally Posted by PrO.GameR
true and false are translated to 1 & 0 in pawn, SetTimer always gives the timerID which is a positive non-zero number, it basically sets Something to true thats all.
|
Woa. That's so intersting. I didn't knew that.
! return 0 for an integer & !! return 1 for an intenger too.
So why, ! can return one for a boolean (or an integer equal to 1) ?
EDIT:So the 'Pro.Gamer''s way is an optimized one?
Re: Little coding questions - For general minor queries 5 -
Nero_3D - 08.01.2017
You simply could have done
PHP код:
Something = bool: SetTimer("SomethingTimer", 1000, false);
because it doesn't matter which values it is as long as it isn't 0 but the problem is timerids start at 0
Re: Little coding questions - For general minor queries 5 -
Lordzy - 09.01.2017
Quote:
Originally Posted by Nero_3D
You simply could have done
PHP код:
Something = bool: SetTimer("SomethingTimer", 1000, false);
because it doesn't matter which values it is as long as it isn't 0 but the problem is timerids start at 0
|
No, they start at 1 and are never used again.
Re: Little coding questions - For general minor queries 5 -
Spmn - 09.01.2017
For actions where a cooldown is needed, you can use unix timestamps or GetTickCount() instead of timers, it is more CPU-efficient.
https://sampforum.blast.hk/showthread.php?pid=2069763#pid2069763
Re: Little coding questions - For general minor queries 5 -
Dayrion - 09.01.2017
So creating another per players var. is more efficiant than a timer per player?
EDIT:
Isn't that possible ?
PHP код:
#if GetVehiclePoolSize() >= 500
new LastShamal[MAX_PLAYERS char],
SVW,
ShamalVW[MAX_VEHICLES char];
#else
new LastShamal[MAX_PLAYERS],
SVW,
ShamalVW[MAX_VEHICLES];
#endif
Re: Little coding questions - For general minor queries 5 -
Lordzy - 09.01.2017
# keywords are PAWN directives, you cannot use them to compare with PAWN natives. Secondly, what are you trying to do with 'char' arrays here? You must have a look over them first before using it. I won't say that player arrays are better than timers. It depends on what you want to do. For instance, if you want to build an anti-spam, you can use GetTickCount to store the last tick and compare it to the current one. Where as on a situation where you need to display random messages every 'X' seconds, I'd prefer a timer.
EDIT : I thought of adding more to this post. To avoid more timers, GetTickCount can also be used with OnPlayerUpdate. But it should be mostly used for short time in game purposes only. An example fit for this would be spawn kill protection. The issue is that OnPlayerUpdate is not called when the game is paused. So if many statements are given under it that are to be executed after given time, it would all get called directly when the player resumes.
Re: Little coding questions - For general minor queries 5 -
PrO.GameR - 09.01.2017
Quote:
Originally Posted by Dayrion
So creating another per players var. is more efficiant than a timer per player?
EDIT:
Isn't that possible ?
PHP код:
#if GetVehiclePoolSize() >= 500
new LastShamal[MAX_PLAYERS char],
SVW,
ShamalVW[MAX_VEHICLES char];
#else
new LastShamal[MAX_PLAYERS],
SVW,
ShamalVW[MAX_VEHICLES];
#endif
|
also @Lordzy
No, using OPU for a spawn protection is purely stupid, we have OnPlayerGiveDamage and OnPlayerWeaponShot and a couple more callbacks to manipulate P2P damage, what would be the point on doing thousands of checks when one might not even get hit in that protection timer?
Timers have another purpose, it's not for doing checks and preventing players from doing something but to allow certain code to execute after a given time.
if you want to prevent a player to do something for a certain amount of time, you need to use a timestamp or tickcount to do that, but if you want something to happen after a certain time, you need a timer (I.E allowing player to report once a minute? timestamp, robbing store when a player stays in certain checkpoint for a minute? timer)
About the second question, #if checks are done compile time, even if what you wrote was allowed by pawn (which isn't) what would be the point? vehicles are created at runtime, think logically, during compile time there is obviously no vehicle so GetVehiclePoolSize() would be 0.
Re: Little coding questions - For general minor queries 5 -
Dayrion - 09.01.2017
Hmmm.. Good point PrO.GameR about the second question..
It soo interesting. *-*
I know timers have different purpose, but I'm talking about optimization, earning time during the execution in game.