AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   user_origin help (https://forums.alliedmods.net/showthread.php?t=9378)

Smokey485 01-16-2005 22:23

user_origin help
 
How do I check every players health, and when one of there health is at 6hp, then it teleports them to


origin, x:1560 y:1372 z-403 stored

help me out her,e I havent coded in 3 - 4 months, I can understand the coding but I cant really write it without getting errors, thx.

Ramirez 01-16-2005 23:05

Use get_user_health
then if their health is below a certain value use set_user_origin..

Smokey485 01-16-2005 23:12

I already knew those two

I wanna know how to check there freakin health
...
I tried
Code:
if(get_user_health(id) == 30) { client_print(id, print_chat, "Your starting to get hungry") }
but that didnt work. I can use origin fine(i think).

Maybe im not checking all players? Do i have to put 30 in quotes?

XxAvalanchexX 01-17-2005 00:01

What mod is this for?

Smokey485 01-17-2005 00:24

The Specialists...

well, heres my coding(horrible)

Code:
new eatburgerregister[3] = { 1533, 1372, -403 }; // Yes? new eat711register[3] = { -2303, 1221, -411 }; // Yes? new eatdinerregister[3] = { -144, -451, -359 }; // Yes? new eatdistburger = 130; // Yes new eatdist711 = 70; // Yes new eatdistdiner = 160; // Yes public eatstatus(id) {     new hp = get_user_health(id)     new players[32], count     get_players(players, count)     new origin[3];     get_user_origin(id, origin) //  new origin1[3] = id //  new origins = get_user_origin(id, origin) // if too far from eat point /*   if(get_distance(origin,eatburgerregister) > eatdistburger) {     client_print(id,print_chat,"* [EAT] You arent at a eat point, go to a 711, Diner, or In & Out");    }    if(get_distance(origin,eat711register) > eatdist711) {     client_print(id,print_chat,"* [EAT] You arent at a eat point, go to a 711, Diner, or In & Out");    } */ if(get_distance(origin,eatdinerregister) > eatdistdiner) {    client_print(id,print_chat,"* [EAT] You arent at a eat point, go to a 711, Diner, or In & Out");    return PLUGIN_HANDLED    }    if(get_distance(origin,eatburgerregister) <= eatdistburger) {    set_user_health(id, hp +21)    }    if(get_distance(origin, eat711register) <= eatdist711) {    set_user_health(id, hp +15)    }    if(get_distance(origin, eatdinerregister) <= eatdistdiner) {    set_user_health(id, hp +35)    } }

BlueRaja 01-17-2005 03:01

Quote:

Originally Posted by Smokey485
I tried
Code:
if(get_user_health(id) == 30) { client_print(id, print_chat, "Your starting to get hungry") }
but that didnt work. I can use origin fine(i think).

Maybe im not checking all players? Do i have to put 30 in quotes?

That only works if their health is exactly 30 - have you tried doing something like <insert code that follows>?
Code:
new iHealth = get_user_health(id) if(iHealth>=15 && iHealth<=30)   //Do something here

btw, your != you're.

Freecode 01-17-2005 03:09

Code:
new eatburgerregister[3] = { 1533, 1372, -403 }; // Yes? new players[32], inum; get_players(players,inum); for(new x = 0; x < inum; x++) {      if(get_user_health(x) =< 30 )      {           set_user_origin(x, eatburgerregister);      } }

BlueRaja 01-17-2005 03:09

[edit]Freecode beat me to it.

Smokey485 01-17-2005 10:12

wow u guys are really helping me here :P

thanks.
But I wanted it at exactly a certain health then teleport em..

cause if someone gets shot by a gun & they get under 10 health or whatever, they'll be teleported then the person who was supposed to kill him wont be able to. This could be good for a hospital thing :P

Question: if x = 0 then how is x the id dude? Confusing, maybe 0 is all players so itll teleport them all, lol. agh.

XxAvalanchexX 01-17-2005 13:18

Good point on the x thing, Freecode's may not work, he forgot to access the players array. Use this instead:

Code:
new eatburgerregister[3] = { 1533, 1372, -403 }; // Yes? new players[32], inum; get_players(players,inum); for(new x = 0; x < inum; x++) {      if(get_user_health(players[x]) =< 30 )      {           set_user_origin(players[x], eatburgerregister);      } }

Also, funny to see that people are still using my code.


All times are GMT -4. The time now is 19:29.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.