Little coding questions - For general minor queries 5

In that case, your current implementation looks fine.

Unless of course you want to adjust the amount of ranks and make it dynamic. In which case you'd create another table for just ranks with this schema:

(rank precedence, rank name, faction ID)

Then you can grab all the ranks with a SELECT * FROM ranks WHERE factionID = etc... you can have n ranks for every faction, adjust that limit based on some other factor whenever you want and you also have a record for each individual rank allowing you to build other data models around this (for example, you could link a player to a rank and a vehicle to a rank then the lookup becomes a JOIN between those three relations).
Reply

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
In that case, your current implementation looks fine.

Unless of course you want to adjust the amount of ranks and make it dynamic. In which case you'd create another table for just ranks with this schema:

(rank precedence, rank name, faction ID)

Then you can grab all the ranks with a SELECT * FROM ranks WHERE factionID = etc... you can have n ranks for every faction, adjust that limit based on some other factor whenever you want and you also have a record for each individual rank allowing you to build other data models around this (for example, you could link a player to a rank and a vehicle to a rank then the lookup becomes a JOIN between those three relations).
I thought the same things but it looks like too much no? I mean, I'll get a toon of "line" (I forget the correct word).
8 * 10 (max factions) = 80.
It's better (performance, optimization, ease of use) to do :
- Like you explained : one line, one rank
- The first method : on line, on faction with 8 ranks max
?
(Sorry for every english mistakes...)
Reply

1.
Quote:
Originally Posted by GaByM
Посмотреть сообщение
Anyone knows the ID of the sound that plays on single player when you purchase a house?
I mean this: https://www.youtube.com/watch?v=qBbRd4o1suY
2. What you think it is better: when you enter in a pickup for a house to automatically teleport you or to enter manually by pressing a key?
Reply

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


2. What you think it is better: when you enter in a pickup for a house to automatically teleport you or to enter manually by pressing a key?
1. Test sound ID 1085.
2. I prefer enter in an house manually.
Reply

You can use as many "saving"/storing systems as you want just try to not make them touch each other's property, so to speak. I personally am using MySQL for everything except for very specific server settings (like gamemode name etc).
Reply

Is there an anti cheat for an invisible player cheat? Or, what method can I use to detect it?
Reply

Quote:
Originally Posted by Arthur Kane
View Post
Is there an anti cheat for an invisible player cheat? Or, what method can I use to detect it?
https://sampforum.blast.hk/showthread.php?tid=633782
Reply

Hey,

wondering why this isn't working and what I'm doing wrong? It sets to 0 by default and you can't pick the style.
PHP Code:
CMD:setstyle(playeridparams[])
{
    new 
        
optionschatstylewalkstyle;
    if(
sscanf(params"d"options)) {
        
SendClientMessage(playeridADM"USAGE:{FFFFFF} /setstyle [Options]");
        
SendClientMessage(playeridDARKGREEN"1. Chat Style|2. Walk Style"); 
        return 
1;
    }
    switch(
options)
    {
        case 
1:
        {
            if(
sscanf(params"d"chatstyle)){
                
SendClientMessage(playeridDARKGREEN"USAGE: /setstyle 1 [StyleID 0-7]");
                return 
1;
            }
            if(
chatstyle || chatstyle 7)
                return 
SendClientMessage(playeridDARKGREEN"That chatstyle does not exist.");
            
PlayerData[playerid][ChatStyle] = chatstyle;
            
SendClientMessage(playeridYELLOW"Your chatstyle has been updated. Chat styles are played when you type.");
        }
       }
     return 
1;

Reply

Your second sscanf is the issue or well both of them kind of are. First you are asking to put "params" into "options" and it should basically be a 1 or a 2. Then when it's a 1, you're asking again if params (aka also options) to be placed into chatstyle. Ergo you have the same thing being placed in both "options" and "chatstyle". You could make the code a bit simpler by using it like this for example:

Code:
CMD:setstyle(playerid, params[]) 
{ 
    new options, style; 

    if(sscanf(params, "ii", options, style)) { 
        SendClientMessage(playerid, ADM, "USAGE:{FFFFFF} /setstyle [Options] [StyleID]"); 
        SendClientMessage(playerid, DARKGREEN, "1. Chat Style|2. Walk Style");  
        return 1; 
    } 

    switch(options) 
    { 
        case 1: 
        { 
            if(chatstyle < 0 || chatstyle > 7) 
                return SendClientMessage(playerid, DARKGREEN, "That chatstyle does not exist."); 

            PlayerData[playerid][ChatStyle] = chatstyle; 
            SendClientMessage(playerid, YELLOW, "Your chatstyle has been updated. Chat styles are played when you type."); 
        } 
    } 
    return 1; 
}

CMD:setstyle(playerid, params[]) 
{ 
    new options, style; 

    if(sscanf(params, "iI(-1)", options, style)) { 
        SendClientMessage(playerid, ADM, "USAGE:{FFFFFF} /setstyle [Options] [StyleID]"); 
        SendClientMessage(playerid, DARKGREEN, "1. Chat Style|2. Walk Style");  
        return 1; 
    } 

    switch(options) 
    { 
        case 1: 
        {
	    if(style == -1) // this means that the user never placed any style id as parameter
	    {
                SendClientMessage(playerid, DARKGREEN, "USAGE: /setstyle 1 [StyleID 0-7]"); 
                return 1; 
            } 
			
            if(chatstyle < 0 || chatstyle > 7) 
                return SendClientMessage(playerid, DARKGREEN, "That chatstyle does not exist."); 

            PlayerData[playerid][ChatStyle] = chatstyle; 
            SendClientMessage(playerid, YELLOW, "Your chatstyle has been updated. Chat styles are played when you type."); 
        } 
    } 
    return 1; 
}
Also indendation lost you somewhere, get the practice to use it correctly please!

My question: Is it possible to make this code shorter somehow? Just asking for convenience sake of course (ZCMD).
Code:
CMD:wi(playerid, params[]) return cmd_windows(playerid, params);
CMD:win(playerid, params[]) return cmd_windows(playerid, params);
CMD:wind(playerid, params[]) return cmd_windows(playerid, params);
CMD:windo(playerid, params[]) return cmd_windows(playerid, params);
CMD:window(playerid, params[]) return cmd_windows(playerid, params);
CMD:windows(playerid, params[])
{
	return 1;
}
Reply

PHP Code:
for(new 1<= 3i++) 
    { 
        if(
PlayerData[playerid][Weapon][i])
            
format(stringsizeof(string), "%s[ %d. %s ]"ffffffff); 

        else
            return 
1;
    }

    
SendClientMessage(playeridWHITEstring); 
So, this shows if the players slot is being used. If there's nothing there, a white blank line shows up. How do I make it not send it?
Reply

****** "isnull".
Reply

i want that when we select spawn class so it must show a skin and text on it, in mine it doesnt show any and we just click >> or << and then we spawn.
plz help me in this
Reply

Hey, how could I get the percentage of a specific amount?
Like, let's say I got $2500 and I want 8% of it, how could I do that?

I'm terrible with math. :c
Reply

Like this?:
PHP Code:
new result = (amount 100) * percentage
Results shows always 0.
Reply

How can I check if a player is online using strfind?

For example, I tried checking if:
PHP Code:
if(strfind(BizData[business][bizOwner], BizData[business][bizOwner], true) != -1
And if the player is online but I'm not too sure how to use it.
Reply

Quote:
Originally Posted by Arthur Kane
View Post
How can I check if a player is online using strfind?

For example, I tried checking if:
PHP Code:
if(strfind(BizData[business][bizOwner], BizData[business][bizOwner], true) != -1
And if the player is online but I'm not too sure how to use it.
Not sure why you specifically want to use strfind. You could loop through online players and compare their name/account IDs, using strcmp is more logical using this. For example:

pawn Code:
GetBusinessOwnerPlayerID(businessid)
{
      if(businessid < 0 || businessid > MAX_BUSINESSES || BizData[businessid][bizValid] == false)
                return false;

      new local_playerName[MAX_PLAYER_NAME];
      for(new i; i <= GetPlayerPoolSize(); i++)
      {
              GetPlayerName(i, local_playerName[i], MAX_PLAYER_NAME);
              if(strcmp(local_playerName[i], BizData[businessid][bizOwner], true) == 0)
              {
                      return i;
              }
       }

       return INVALID_PLAYER_ID;
}
Obviously adjust as needed. You could also get and store the players names as they connect for future reference rather than GetPlayerName (that's a method I personally use). You could also store business owners as account IDs and check those.
Reply

Hi, got a problem and not sure how to fix it.
PHP Code:
error 047: array sizes do not match, or destination array is too small 
Two of these errors:
PHP Code:
enum E_NUM{
      
carOwner[128],
      
carPlates[32],
}; 
And the error occurs here:
PHP Code:
stock LoadCars()
{
    new 
        
string[128], FileName[128]; 
    for(new 
0MAX_PLAYER_VEHICLESi++) 
    {
        
format(FileNamesizeof(FileName), "PlayerVehicles/%d.ini"i);
        if(
fexist(FileName)){
  
                   
CarData[i][carOwner] = dini_Get(FileName"carOwner");  
                   
CarData[i][carPlates] = dini_Get(FileName"carPlates"); 
Edit:

By changing carOwner[128] to carOwner[255] it fixed the error for carOwner. Not sure why to be honest if anyone could explain that. Error still occurs with plates.
Reply

Can somebody tell me why the dynamic 3d text labels are attached to wrong players?
Reply

What can you do with MySQL that you can't do with SQL?
Reply

Quote:
Originally Posted by Arthur Kane
View Post
What can you do with MySQL that you can't do with SQL?
Threaded queries. Easy web implement.
MySQL and SQL are different things, MySQL is a program used and SQL is a language. The right word you should use in this is SQLite.
Reply


Forum Jump:


Users browsing this thread: 20 Guest(s)