Little coding questions - For general minor queries 5
#61

How could I use something other then the TogglePlayerSpectating? What all does it do? Does it just freeze the player and make him disappear? I could do that myself. It's just because when I toggle back from spectating, it respawns me and OnPlayerSpawn is called. I don't like that. If I just set my player's position or virtual and froze me wouldn't it be the same?
Reply
#62

Quote:
Originally Posted by backwardsman97
How could I use something other then the TogglePlayerSpectating? What all does it do? Does it just freeze the player and make him disappear? I could do that myself. It's just because when I toggle back from spectating, it respawns me and OnPlayerSpawn is called. I don't like that. If I just set my player's position or virtual and froze me wouldn't it be the same?
I had a similar issue, but use timers and variables to store the players weapon data and position and all will be fixed!
Reply
#63

How to use SetTimerEx properly?

I need it for an anti spam of a drug script. I first use SetTimer and created a function, CrackUses, but this works for player id 0 only, so someone told me to use SetTimerEx, but i dont know how to.... : /
Reply
#64

pawn Code:
SetTimerEx(funcname[], interval, repeating, const format[], {Float,_}:...)
An example for a playerid in a function would be like.
pawn Code:
SetTimerEx("SomeFunction",1000,1,"i",playerid);
The format is like this.
Code:
i 	 Stands for an integer parameter.
d 	Exactly the same as i.
a 	Passes an array, the next parameter must be an integer ("i") with the array's size.
s 	Stands for a string parameter.
f 	Stands for a float parameter.
b 	Stands for a boolean parameter.
http://www.sareallife.org/sampwiki/w...etTimerEx.html

And for two parameters.
pawn Code:
SetTimerEx("Fix",2000,0,"ii",playerid,GetPlayerVehicleID(playerid);

Reply
#65

What's the current pickup limit?
Reply
#66

Quote:
Originally Posted by [RP
Jolteon ]
What's the current pickup limit?
I think it's 400.
Reply
#67

Hi!

This isn't a problem, I'm just wondering how I could make an infinite loop of to check wheter a player is 15 meters away from a point (using PlayerToPoint)
Reply
#68

Quote:
Originally Posted by GTA_Rules
Hi!

This isn't a problem, I'm just wondering how I could make an infinite loop of to check wheter a player is 15 meters away from a point (using PlayerToPoint)
SetTimer( ... ).
Reply
#69

How to check if the player is the driver of the vehicle? I tried it with:
pawn Code:
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
{
}
But it doesn't works.
Reply
#70

Quote:
Originally Posted by Torekk
How to check if the player is the driver of the vehicle? I tried it with:
pawn Code:
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
{
}
But it doesn't works.
Code:
// On top of your script:

new vehicle;

// In OnGameModeInit

vehicle = AddStaticVehicle(...)

// Outside other functions (most likely at the end of your script).

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new numero = GetPlayerVehicleID(playerid);
        if(numero == vehicle)
        {
		// Do something here
		}
	}

    return 1;
}
Sorry if the intendation got fucked.
Reply
#71

Well, thanks for your help at first. But how would I then "include" into this command?
pawn Code:
if (strcmp("/fix", cmdtext, true)==0)
{
     if((!IsPlayerInAnyVehicle(playerid)) && (GetPlayerState(playerid) != PLAYER_STATE_DRIVER))
     {
          SendClientMessage(playerid, COLOR_RED, "You are not in a vehicle or you're not the driver of it!");
     } else {
          SetVehicleHealth(GetPlayerVehicleID(playerid), 1000);
          PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
     }
     return 1;
}
Edit: That command works, but when you enter as a passenger, you can still repair the vehicle, so I guess that PLAYER_STATE_DRIVER is either not available or wrong.

Edit2: It appears that you can't use GetPlayerState(playerid) != PLAYER_STATE_DRIVER, you'll have to make it "vice versa".
Reply
#72

Quote:
Originally Posted by Torekk
Well, thanks for your help at first. But how would I then "include" into this command?
pawn Code:
if (strcmp("/fix", cmdtext, true)==0)
{
     if((!IsPlayerInAnyVehicle(playerid)) && (GetPlayerState(playerid) != PLAYER_STATE_DRIVER))
     {
          SendClientMessage(playerid, COLOR_RED, "You are not in a vehicle or you're not the driver of it!");
     } else {
          SetVehicleHealth(GetPlayerVehicleID(playerid), 1000);
          PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
     }
     return 1;
}
Edit: That command works, but when you enter as a passenger, you can still repair the vehicle, so I guess that PLAYER_STATE_DRIVER is either not available or wrong.

Edit2: It appears that you can't use GetPlayerState(playerid) != PLAYER_STATE_DRIVER, you'll have to make it "vice versa".
remove the parentheses around the getplayerstate
Reply
#73

Quote:
Originally Posted by Torekk
Well, thanks for your help at first. But how would I then "include" into this command?
pawn Code:
if (strcmp("/fix", cmdtext, true)==0)
{
      if((!IsPlayerInAnyVehicle(playerid)) && (GetPlayerState(playerid) != PLAYER_STATE_DRIVER))
      {
           SendClientMessage(playerid, COLOR_RED, "You are not in a vehicle or you're not the driver of it!");
      } else {
           SetVehicleHealth(GetPlayerVehicleID(playerid), 1000);
           PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
      }
      return 1;
}
Edit: That command works, but when you enter as a passenger, you can still repair the vehicle, so I guess that PLAYER_STATE_DRIVER is either not available or wrong.

Edit2: It appears that you can't use GetPlayerState(playerid) != PLAYER_STATE_DRIVER, you'll have to make it "vice versa".
Why not do like this?

pawn Code:
if (strcmp("/fix", cmdtext, true)==0)
{
   if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
   {
      SetVehicleHealth(GetPlayerVehicleID(playerid), 1000);
      PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);      
   }
   else
   {
      SendClientMessage(playerid, COLOR_RED, "You are not in a vehicle or you're not the driver of it!");
   }
   return 1;
}
No need for the check for if they are in the vehicle because their state can't be driver if they aren't in a vehicle.
Reply
#74

Quick question:
I'm trying to make it so when a player calls a Taxi it will send a message to taxi drivers only, I've searched around abit' and all ive found are team chats taht use TEAM_GROVE for example... To identify a player as a taxi driver in my script I use
pawn Code:
pJob[playerid] = 4;
Any help appreciated, thanks.

Reply
#75

Maybe use gTeam then a check if the player is in the team and send him a message
Reply
#76

Quote:
Originally Posted by Matthias™
Maybe use gTeam then a check if the player is in the team and send him a message
I dont really like using gTeam, is there any other way?

Edit: I've worked out how to do it by looking at /Report commands
Reply
#77

- fixed -
Reply
#78

as i for some reason cant modify the above one
i got to make this new post

Code:
hPickup[Houseid] = CreatePickup(1273,1,x,y,z);
// xyz and Houseid are nice defined in a stock
wont let me spawn a pickup nor will they allow text when i
do on player pickup i tried a couple of streamers
but how can i make it that a id in a pickup id would be useable

edit fixed aswell
Code:
god = CreatePickup(1273,1,x,y,z);;
hPickup = god
Reply
#79


It is possible to refer to a command in a function , without re-typing the code that's used to make the command work ? For example if you created a menu and you want to execute the command ''/help'' if he has chosen " case 0 ". Etc etc.
Reply
#80

Quote:
Originally Posted by Biofreeze
It is possible to refer to a command in a function , without re-typing the code that's used to make the command work ? For example if you created a menu and you want to execute the command ''/help'' if he has chosen " case 0 ". Etc etc.
OnPlayerCommand(playerid, "/help");

Leopard
Reply


Forum Jump:


Users browsing this thread: 19 Guest(s)