SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 25/04/2016, 10:20 PM   #2801
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,248
Reputation: 525
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by runcis View Post
how would you write this, i forgot it isn't working
By the looks, switch your || with &&.
Sew_Sumi is offline   Reply With Quote
Old 25/04/2016, 10:26 PM   #2802
thaKing
Huge Clucker
 
thaKing's Avatar
 
Join Date: Feb 2014
Location: Mushroom fields
Posts: 293
Reputation: 37
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by Sew_Sumi View Post
By the looks, switch your || with &&.
I want it to work something like

If trailer then 1 to 3,
if house then 4 to 10,
if aprt. then 11 to 12

after that comes function that sets house varibles with info. i have constant with interior ids

edit: didn't work btw
editLOL: tried something else..
PHP Code:
if (int < (house[id][houseType] == 0) ? (1) : (4) || int > (house[id][houseType] == 0) ? (3) : (10))
            return 
SendErrorMsg(playerid"Interior was invalid or isn't available for this house type."); 
still didn't work btw
thaKing is offline   Reply With Quote
Old 25/04/2016, 10:30 PM   #2803
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,248
Reputation: 525
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by runcis View Post
I want it to work something like

If trailer then 1 to 3,
if house then 4 to 10,
if aprt. then 11 to 12

after that comes function that sets house varibles with info. i have constant with interior ids

edit: didn't work btw
Use
PHP Code:
printf("Interior %i",int); 
to see what interior is being passed to it.

Quote:
Originally Posted by runcis View Post
PHP Code:
if (int < (house[id][houseType] == 0) ? (1) : (4) || int > (house[id][houseType] == 0) ? (3) : (10))
            return 
SendErrorMsg(playerid"Interior was invalid or isn't available for this house type."); 
still didn't work btw
That's even worse...



The actual issue with your code is your if statements are screwed...


Go back to what you had first entering the thread, and check all of these lines...

PHP Code:
if (int 11 || int 12)) 
You have an extra ) in each line.
Sew_Sumi is offline   Reply With Quote
Old 25/04/2016, 10:46 PM   #2804
thaKing
Huge Clucker
 
thaKing's Avatar
 
Join Date: Feb 2014
Location: Mushroom fields
Posts: 293
Reputation: 37
Talking Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by Sew_Sumi View Post
Use
PHP Code:
printf("Interior %i",int); 
to see what interior is being passed to it.



That's even worse...



The actual issue with your code is your if statements are screwed...


Go back to what you had first entering the thread, and check all of these lines...

PHP Code:
if (int 11 || int 12)) 
You have an extra ) in each line.
fuck yeah! didn't saw - blind as fuck
thaKing is offline   Reply With Quote
Old 28/04/2016, 08:11 PM   #2805
[XST]O_x
High-roller
 
[XST]O_x's Avatar
 
Join Date: Aug 2009
Posts: 1,962
Reputation: 94
Default Re: Little coding questions - For general minor queries 5

A question I never got a chance to ask - How do you check if a player is paused?
I don't get what "OnPlayerUpdate returns 0" means. How do I check what the callback returns?
[XST]O_x is offline   Reply With Quote
Old 28/04/2016, 08:14 PM   #2806
thaKing
Huge Clucker
 
thaKing's Avatar
 
Join Date: Feb 2014
Location: Mushroom fields
Posts: 293
Reputation: 37
Default Re: Little coding questions - For general minor queries 5

use emmet_'s new-samp callbacks, there are many callbacks, also OnPlayerPause, OnPlayerResume
https://github.com/emmet-jones/New-SA-MP-callbacks
thaKing is offline   Reply With Quote
Old 28/04/2016, 08:27 PM   #2807
Crayder
Banned
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,329
Reputation: 652
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by [XST]O_x View Post
A question I never got a chance to ask - How do you check if a player is paused?
I don't get what "OnPlayerUpdate returns 0" means. How do I check what the callback returns?
What OnPlayerUpdate returns has absolutely nothing to do with the player pausing.

When the player's pause or go AFK OnPlayerUpdate stops calling for them. Look at how it's tracked in the script runcis linked you too, it's very easy to implement.
Crayder is offline   Reply With Quote
Old 04/05/2016, 01:26 AM   #2808
Kimble
Big Clucker
 
Kimble's Avatar
 
Join Date: Nov 2015
Posts: 80
Reputation: 4
Question Re: Little coding questions - For general minor queries 5

Does anyone know why this happens?

Code:
printf("inputtext = %s", inputtext); // Prints fine.
strmid(Account[playerid][eEmail], inputtext, 0, strlen(inputtext)); // Saves the inputtext to this variable.
printf("Account[playerid][eEmail] = %s", Account[playerid][eEmail]); // Prints blank.
And then look at this:

Code:
printf("inputtext = %s", inputtext); // Prints fine.
strmid(Account[playerid][eEmail], inputtext, 0, strlen(inputtext), 64); // Saves the inputtext to this variable.
printf("Account[playerid][eEmail] = %s", Account[playerid][eEmail]); // Prints fine.
I thought the "maxlength" parameter in strmid was optional?

Or it doesn't work in this case since this is a enum element and you can't get the size of those (like sizeof() doesn't work on enum elements)?

Anyway if someone can confirm or give another explanation i would be thankful.
Kimble is offline   Reply With Quote
Old 04/05/2016, 06:20 AM   #2809
]Rafaellos[
Gangsta
 
Join Date: Feb 2012
Location: Cyprus
Posts: 731
Reputation: 48
Default Re: Little coding questions - For general minor queries 5

If you want to just copy inputtext to Account[playerid][eEmail], then:

pawn Code:
strcat((Account[playerid][eEmail][0] = EOS, Account[playerid][eEmail]), inputtext, 64);
__________________
]Rafaellos[ is offline   Reply With Quote
Old 04/05/2016, 06:41 AM   #2810
Miller007
Big Clucker
 
Join Date: Jun 2014
Posts: 52
Reputation: 0
Default Re: Little coding questions - For general minor queries 5

Which is the fastest ini system ?
Miller007 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
how to make a soldier aotumaticly be general when the general dies ? AlbanianGuy Scripting Help 35 13/05/2012 03:35 PM
Minor problem Desert Help Archive 4 17/03/2010 06:24 PM
Counting with mysql queries actiwe Help Archive 2 26/02/2010 02:36 PM
SQL queries using GROUP BY Dabombber Help Archive 1 05/10/2009 07:47 PM


All times are GMT. The time now is 12:13 PM.


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