Jump to content

Newb Confusion...


raa

Recommended Posts

Most of my "scripting" experience is with pawn(I believe that is the correct name). http://www.amxmodx.org/doc/source/scripting/intro.htm

 

I've made a few things with php and am still learning when I have time. I've noticed php is a little different then what I'm used in that the below code

 

<?
  $name = "yourname";
  echo $name;
?>

 

just blurps out and runs when you load it.

 

however, with what I'm used to you would have to make a function like,

 


public displayname(id)
{
new name[32]
name[id] = "yourname"
client_print(id,print_chat,"Your name is %s ", name)
}

 

that would print "yourname" (if i setup a command for you to type) when you typed the command.

 

 

 

I see the uses of having the code in php just get ran through when the page is loaded. However, I need to have some power over what is ran and when. I did a little reading, but I'm not sure what the terminology is, so searching isn't turning up much.

 

I've looked into using PHP functions like

 

function func1()
{
// DO STUFF
}

 

but I didn't like how the passing of variables was working out. seemed crazy having to put every single variable used in the .php within the function "()" in-order for the function to work.

 

anyway I know you guys are way advanced and get a lot of noobs wandering in here asking stupid questions like I have, but If I could please get a little direction and advice. Links and such help I guess and I'll take w/e you have time to offer, but what I'm really needing atm is some human direction.

 

thanks for reading... 

Link to comment
Share on other sites

Functions are about the best way to control what gets ran and when. If you don't want to pass vars in the function itself, then you can call those vars as global.

 

<?php

$x=1;
$y=2;
$z=5;


function addem()
{
   global $x,$y,$z,$total;

   $total=$x+$y+$z;
}

addem();

echo $total;

?>

 

Returns 8

 

Hope it helps a bit

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.