Little coding questions - For general minor queries 5

Quote:
Originally Posted by admantis
Посмотреть сообщение
Hello, how can I do (using Incognito's streamer plugin) that a dynamic object will show in every interior, except for 0?
I really don't know because I've never used any objects, but you can try this way:

Код:
if(GetPlayerInterior(playerid) != 0)
{
	// code here
}
Source: https://sampwiki.blast.hk/wiki/GetPlayerInterior
Reply

Anyone know of a good formal handshake animation?
Reply

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Anyone know of a good formal handshake animation?
Bump.

EDIT: I could also use a good and efficient function for detecting if a player is paused.
Reply

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Bump.

EDIT: I could also use a good and efficient function for detecting if a player is paused.
OnPlayerUpdate is not called when the player pauses, so there could be multiple ways If you are creative.
For example, set any variable to "1" when OnPlayerUpdate is called, and under a five seconds timer, lower it. Then, you can check if the variable is 0 and if so, the player is paused.

With that info I'm sure you could work around it
About the animation; I am highly doubtful such animation exists in San Andreas. I've lurked about 90% of the animations in an experiment a year ago and don't remember anything similar, I'm pretty sure a "belly crash" is not a formal handshake!
Reply

i got a simple question,
i want to make a function that takes unlimited args
easy.. but i want this function to only accept strings as the arguments.

pawn Код:
stock CreateNew%$%&%^$(name[],...)
{
    return 1;
}
im not sure how to enforce that its a string(s) being passed.
i know how to enforce a tag but not sure about the string.

thanks
Reply

What is the use of #emit function ?
Reply

Quote:
Originally Posted by leo3412
Посмотреть сообщение
What is the use of #emit function ?
this page should sum it up for ya
https://sampforum.blast.hk/showthread.php?tid=315531
Reply

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
Thank you +1 REP
Reply

How can I use timers if I want to show a player an area(with SetPlayerCameraPos and SetPlayerCameraLookAt) for 10 seconds?
Reply

What is the police colour code of this picture:
http://forum.sa-mp.com/attachment.ph...1&d=1337099820
Reply

I've taken a looong break from the programming world and now I forgot...everything. The dumb question is the following: If I have a, let's say AFK variable, should I set it to -1 or 0 in onplayerconnect to make sure the player will not be declared AFK when they join? What's the difference in using -1 or 0 though?
Reply

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
That all depends on how you use the variable, it's entirely up to you really.
But if you are using boolean values pretty much anything apart from 0 will be true and only 0 will be false.
Thanks, this cleared it up.
Reply

Why "EditAttachedObject / SelectObject" doesn't working, if this function call from OnDialogResponse ? How fix this?
Reply

I have two questions,
1. Is there a way to put objects ONLY in a X virtual world? (I'm building /DM area and i don't want the regular world will see the objects).
2. What is streamer ? How it can be help me?

Thanks.
Reply

Quote:
Originally Posted by im
Посмотреть сообщение
Quick n00b question.

I see that a lot of people use:
Код:
if(IsPlayerConnected(targetid)){
  //do something
}else{
 SendClientMessage(playerid, COLOR_WHITE, "Player not connected!");
}
return 1;
Is anything wrong to use this?:
Код:
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Player not connected!");
 // do something here..
return 1;
I find the second code much easier to read since there are not 999 if / else in the code.
Is anything wrong with the second example? Does it affect teh performance in any way?

I know is a noob question.. Just asking because I don't really know much stuff about how samp and NOT works in SAMP.
Perfectly fine.
Reply

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
I want to manipulate the text from OnPlayerText before sending it.
I know to use return 0 and format it instead that's not what I'm asking.

What's the best way?

It seems like using 'strins' on the parameter 'text' just doesn't work. All my commands stop working (weird).


Also, should I do this:
pawn Код:
text = TextEditFunction(text);
and let the function return the changed text or is there another way?
I think formatting is the best way.
Reply

Quote:
Originally Posted by im
Посмотреть сообщение
Quick n00b question.

I see that a lot of people use:
Код:
if(IsPlayerConnected(targetid)){
  //do something
}else{
 SendClientMessage(playerid, COLOR_WHITE, "Player not connected!");
}
return 1;
Is anything wrong to use this?:
Код:
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Player not connected!");
 // do something here..
return 1;
I find the second code much easier to read since there are not 999 if / else in the code.
Is anything wrong with the second example? Does it affect teh performance in any way?

I know is a noob question.. Just asking because I don't really know much stuff about how samp and NOT works in SAMP.
They are both perfect in their ways.
Reply

Quote:
Originally Posted by im
Посмотреть сообщение
Quick n00b question.

I see that a lot of people use:
Код:
if(IsPlayerConnected(targetid)){
  //do something
}else{
 SendClientMessage(playerid, COLOR_WHITE, "Player not connected!");
}
return 1;
Is anything wrong to use this?:
Код:
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Player not connected!");
 // do something here..
return 1;
I find the second code much easier to read since there are not 999 if / else in the code.
Is anything wrong with the second example? Does it affect teh performance in any way?

I know is a noob question.. Just asking because I don't really know much stuff about how samp and NOT works in SAMP.
Personally, I found the first method the easiest when I started out, in case I messed something up and forgot something, but now I prefer the second method, as it's cleaner and easier to do really.
Reply

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
I'm just scripting a minigame, the one where in a grid of square objects a random object is deleted every now and then and players have to survive. (I think it's called "Don't Get Wet" so the general prefix is "DGW")

I'm concerned about how I select the random object, right now I have this code:

pawn Код:
new tmpX = random(dgw_gridSize), tmpY = random(dgw_gridSize);
while(!IsValidDynamicObject(dgw_gridObj[tmpX][tmpY]))
{
    tmpX = random(dgw_gridSize), tmpY = random(dgw_gridSize);
}
// dgw_gridSize = 8 - so the grid has 64 blocks in total
You don't need to tell me that this is a bad method!

When there is only one object left, this code can take a lot of time and keep the server waiting sometimes, because it's random there's no knowing what object it might choose.

For instance, for 1000 calls of that while loop the randomiser could always choose an invalid one and keep missing the one remaining block.


I couldn't think of a better way (Probably because I woke up not long ago!) can anyone else? I'm sure there's a much better way to do this!
I have never worked with objects.

I suppose you know starting object IDs which can be deleted( so you are not deleting some random houses in LV if the game is in LS. You want only rocks in game to be able to be deleted ).
If so, create an array where you store the IDs and at the end '\0'. The number of IDs in your array equals strlen(array)-you can use in radom().

Once you delete a object, clean the place in array and put in order other IDs. ( I know this is confusing. Whit the example it will be a much clearer. IE: Starting array array[]={1,34,45,23,5,35,76,67,...}, once you have randomly deleted 23 array will look like array[]={1,34,45,?,5,35,76,67,...}, now you need every array slot after 23 move one place left so it will look like array[]={1,34,45,5,35,76,67,...} and you can start from beginning. Don't forget to move the '\0' also one place left. )
I think this is the best way.
Reply

Right now I have:
switch (reason)
{
case blabla: formatblablabla;
case bloblo: formatblobloblo;
return blublublu;
}

Am I able to use something like:
switch (reason)
{
case blablabla: formatblublu AND formatbleble
}

Always when I try to add two lines / codes after 1 case it will give me errors...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)